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:

  1. Print the first item of the list - print(li[0])
  2. Print the last item of the list - print(li[-1])

Bonus:

  1. Print random item of the list
from random import choice
print(choice(li))