Python: Accessing List Elements
Posted: Tue Apr 07, 2026 5:08 pm
Code: Select all
list_of_some_NFL_teams = list(("Chiefs", "Eagles", "Lions", "Bills", "Texans"))
print(list_of_some_NFL_teams[0])
# Above prints out Chiefs because positive indexes start with 0
print(list_of_some_NFL_teams[2:4])
# Above prints the second to the fourth index, but not including the fourth index.
# Prints out Lions and Bills