Created
May 5, 2019 14:05
-
-
Save nunenuh/c0eb00273f068bac15cdc98d5f33e74c to your computer and use it in GitHub Desktop.
Idiomatic Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Looping Over Collection with Indice Forward | |
colors = ["red", "green", "blue"] | |
# bad | |
for i in range(len(colors)): | |
print(i,'--',colors[i]) | |
# good | |
for i, color in enumerate(colors): | |
print(i, '--', color) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment