Advertisement
OreganoHauch

loop through dictionary?

Mar 30th, 2020
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. # Difficult? (Entries in a dictionary, integer variables.)
  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(5):
  13. print(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 i in range(5):
  26. print(string_dictionary[xi])
  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(5):
  37. print(xi)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement