Skip to content

Instantly share code, notes, and snippets.

@Yunkou
Last active August 30, 2017 17:56
Show Gist options
  • Save Yunkou/856de1ba198cfc5f75215cb2b71f7b8c to your computer and use it in GitHub Desktop.
Save Yunkou/856de1ba198cfc5f75215cb2b71f7b8c to your computer and use it in GitHub Desktop.
Using zip()
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