Accessing list elements in {lang}
Lists are ordered, meaning each element has a numbered position known as its index. We access a list element by referring to its index number.
Lists use zero-based indexing, so the first element in a list has an index of 0, the second element has an index of 1, etc.
We’re using bracket notation ([]) with the index after the name of the list to access the element:
myList = ["Hello world!", 32, False]
print(myList[0]) # Output: "Hello world!"
print(myList[1]) # Output: 32
print(myList[2]) # Output: False
Assignment
Follow the Coding Tutorial and let's play with some arrays.
Hint
Look at the examples above if you get stuck.