access_list_items.md
April 8, 2022 ยท View on GitHub
Access List Items
Given the following list li = [2, 0 ,1, 7, 2, 0, 2, 2] perform the following:
- Print the first item of the list -
print(li[0]) - Print the last item of the list -
print(li[-1])
Bonus:
- Print random item of the list
from random import choice
print(choice(li))