Python: Accessing List Elements

Post Reply
User avatar
Jason
Site Admin
Posts: 767
Joined: Sun Dec 21, 2025 8:56 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
 

POSTREACT(ions) SUMMARY

Post Reply