Advertisement
Guest User

Untitled

a guest
May 25th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. colors = ['red', 'green', 'blue', 'orange', 'purple']
  2.  
  3. # simple way
  4. index = 0
  5. for color in colors:
  6. print(f'{index} ---> {color}')
  7. index += 1
  8.  
  9. # pythonic way
  10. for index, color in enumerate(colors):
  11. print(f'{index} ---> {color}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement