Python: Accessing List Elements

Post Reply
User avatar
Jason
Site Admin
Posts: 809
Joined: Tue Jul 01, 2025 10:13 am

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