2. Accessing list elements. In Python
, you can access list elements by referencing their index value.
Consider the list a_list = [10, 20, 30, 40, 50]
. To access the number 20 in the list, you would
use the syntax a_list[1]
. Note that indexation starts at 0 in Python.
The list object, a_list
has been defined for you. Do the following things to that list:
1. Print the 3rd element.
2. Change the 5th element to the list [0, 1]
.
3. Change the 2nd element to the empty list[]
.