Created
March 2, 2016 09:05
-
-
Save davidbj/88c553556e8d2538c961 to your computer and use it in GitHub Desktop.
find function demo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def find(origin=None, items=None): | |
| dc = {} | |
| lst = [] | |
| idx=0 | |
| for i in items: | |
| for j in origin: | |
| if i == j: | |
| lst.append(origin.index(j, idx)) | |
| idx=origin.index(j)+1 | |
| else: | |
| continue | |
| dc[i] = tuple(lst) | |
| lst=[] | |
| idx=0 | |
| return dc | |
| find(origin=[1,3,5,4,1,3], items=[1, 3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment