Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> string = "this is string"
- >>> dict = {}
- >>> y=0
- >>> for x in string.strip():
- ... if x in dict.keys():
- ... dict[x] = [dict[x], y]
- ... else:
- ... dict[x] = y
- ... y +=1
- ...
- >>> dict
- {'t': [0, 9], 'h': 1, 'i': [[2, 5], 11], 's': [[3, 6], 8], ' ': [4, 7], 'r': 10, 'n': 12, 'g': 13}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement