Last active
January 27, 2020 14:28
-
-
Save fabsta/059b91f6e879323af8283de0923f511f to your computer and use it in GitHub Desktop.
[python iterate list] Iterate through a python list #python #pandas
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
# list = [1, 3, 5, 7, 9] | |
# Using for loop | |
for i in list: | |
print(i) | |
# 1 | |
# 3 | |
# for index | |
for i in range(length): | |
print(list[i]) | |
# 1 | |
# 3 | |
# Using list comprehension | |
[print(i) for i in list] | |
# 1 | |
# 3 | |
# # Using enumerate() | |
for i, val in enumerate(list): | |
print (i, ",",val) | |
# 0 , 1 | |
# 1 , 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment