Page 1 of 1

Python: Accessing List Elements

Posted: Tue Aug 26, 2025 5:03 am
by Jason

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