Last active
March 11, 2021 04:50
-
-
Save studiawan/6535632 to your computer and use it in GitHub Desktop.
Accessing python list
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
# declare and fill list | |
courses = ['j2ee', 'progjar', 'paal'] | |
# iterate each element | |
for course in courses: | |
print(course) | |
# get index and value with enumerate | |
for index, value in enumerate(courses): | |
print(index, value) | |
# get element using index | |
# python uses zero-based index | |
print(courses[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment