sanderl

egh

Feb 15th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. s = "We tried list and we tried dicts also we tried Zen"
  2. dic = {}
  3.  
  4. a = int(0)
  5. dic_length = int(0)
  6.  
  7. x = int(0)
  8. y = int(0)
  9. z = int(0)
  10.  
  11.  
  12. for word in s.split(" "):
  13.     dic[a] = word
  14.     a += 1
  15.  
  16. for value in dic.items():
  17.     dic_length += 1
  18.  
  19. print(dic)
  20. print(dic_length)
  21.  
  22. while x < dic_length:
  23.  
  24.     while y < dic_length:  # while not at end of dic
  25.         if dic.get(x) == dic.get(y):
  26.             print("loop 2 ", x, y, z)
  27.             print(dic.get(x))
  28.             print(dic.get(y))
  29.             z += 1
  30.  
  31.         y += 1
  32.         dic2 = dic.get(y)
  33.  
  34.     x += 1
  35.  
  36.     print("loop 1 ", x, y, z)
Advertisement
Add Comment
Please, Sign In to add comment