Last active
August 30, 2017 17:56
-
-
Save Yunkou/856de1ba198cfc5f75215cb2b71f7b8c to your computer and use it in GitHub Desktop.
Using zip()
This file contains 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
x_list = [1, 2, 3] | |
y_list = [2, 4, 6] | |
# The bad way | |
for i in range(len(x_list)): | |
x = x_list[i] | |
y = y_list[i] | |
print(x, y) | |
# The good way | |
for x, y in zip(x_list, y_list): | |
print(x, y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment