Advertisement
OreganoHauch

loop through dictionary?_2

Mar 30th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. # Difficult?
  2.  
  3. string_dictionary = {
  4. 1: " +1. open+: +1",
  5. 2: " +2. high+: +1",
  6. 3: " +3. low+: +1",
  7. 4: " +4. close+: +1",
  8. 5: " +5. volume+: +5"
  9. }
  10.  
  11.  
  12. for i in range(1,5):
  13. print(len(string_dictionary[i])
  14.  
  15. # More difficult? (Entries in a dictionary, string + integer variables.)
  16.  
  17. string_dictionary = {
  18. x1: " +1. open+: +1",
  19. x2: " +2. high+: +1",
  20. x3: " +3. low+: +1",
  21. x4: " +4. close+: +1",
  22. x5: " +5. volume+: +5"
  23. }
  24.  
  25. for key in string_dictionary:
  26. print(string_dictionary[key])
  27.  
  28. # Insanely difficult? (Just the variables outside of a dictionary.)
  29.  
  30. x1 = " +1. open+: +1",
  31. x2 = " +2. high+: +1",
  32. x3 = " +3. low+: +1",
  33. x4 = " +4. close+: +1",
  34. x5 = " +5. volume+: +5"
  35.  
  36. for i in range(1,5):
  37. print(xi)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement