Created
May 5, 2019 14:02
-
-
Save nunenuh/59cd3e64c0d96590f18c48fdd8dec675 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 Two Collection | |
names = ["raymond", "rachel","matthew"] | |
colors = ["red", "green", "blue"] | |
# bad | |
n = min(len(names), len(colors)) | |
for i in range(n): | |
print(names[i], '--', colors[i]) | |
# good | |
for name, color in zip(names, colors): | |
print(name, '--', color) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment