Skip to content

Instantly share code, notes, and snippets.

@studiawan
Last active March 11, 2021 04:50
Show Gist options
  • Save studiawan/6535632 to your computer and use it in GitHub Desktop.
Save studiawan/6535632 to your computer and use it in GitHub Desktop.
Accessing python list
# 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