Guest User

Untitled

a guest
Jan 16th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. list = ['abc', 'def']
  2. map_list = []
  3.  
  4. for s in list:
  5. t = (list[s], 1)
  6. map_list.append(t)
  7.  
  8. list1 = ['abc', 'def']
  9. list2=[]
  10. for t in list1:
  11. for h in t:
  12. list2.append(h)
  13. map_list = []
  14. for x,y in enumerate(list2):
  15. map_list.append(x)
  16. print (map_list)
  17.  
  18. >>>
  19. [0, 1, 2, 3, 4, 5]
  20. >>>
  21.  
  22. list1 = ['abc', 'def']
  23. map_list=[]
  24. for x,y in enumerate(list1):
  25. map_list.append(x)
  26. print (map_list)
  27.  
  28. >>>
  29. [0, 1]
  30. >>>
  31.  
  32. orig_list = ['abc', 'def']
  33. map_list = [(el, 1) for el in orig_list]
  34.  
  35. for s in mylist:
  36. t = (mylist[s], 1)
  37.  
  38. for s in lists:
  39. t = (s, 1)
  40. map_list.append(t)
  41. print map_list
  42. #[('abc', 1), ('def', 1)]
  43.  
  44. for s in my_list: # here s is element of list not index of list
  45. t = (s, 1)
  46. map_list.append(t)
  47.  
  48. for i,s in enumerate(my_list): # here i is the index and s is the respective element
  49. t = (s, i)
  50. map_list.append(t)
Add Comment
Please, Sign In to add comment