Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- list = ['abc', 'def']
- map_list = []
- for s in list:
- t = (list[s], 1)
- map_list.append(t)
- list1 = ['abc', 'def']
- list2=[]
- for t in list1:
- for h in t:
- list2.append(h)
- map_list = []
- for x,y in enumerate(list2):
- map_list.append(x)
- print (map_list)
- >>>
- [0, 1, 2, 3, 4, 5]
- >>>
- list1 = ['abc', 'def']
- map_list=[]
- for x,y in enumerate(list1):
- map_list.append(x)
- print (map_list)
- >>>
- [0, 1]
- >>>
- orig_list = ['abc', 'def']
- map_list = [(el, 1) for el in orig_list]
- for s in mylist:
- t = (mylist[s], 1)
- for s in lists:
- t = (s, 1)
- map_list.append(t)
- print map_list
- #[('abc', 1), ('def', 1)]
- for s in my_list: # here s is element of list not index of list
- t = (s, 1)
- map_list.append(t)
- for i,s in enumerate(my_list): # here i is the index and s is the respective element
- t = (s, i)
- map_list.append(t)
Add Comment
Please, Sign In to add comment