Lists
Creating Lists
numbers = [1, 2, 3]
mixed = ["Apple", 12, 45.7, False]
nested = ["Apple", ["Banana", "Cherry"], "Durian"]Accessing Items
fruits = ["Apple", "Banana", "Cherry"]
print(fruits[0]) # Apple
print(fruits[-1]) # CherrySlicing
letters = ["P", "y", "t", "h", "o", "n"]
print(letters[2:5]) # ['t', 'h', 'o']
print(letters[:3]) # ['P', 'y', 't']
print(letters[3:]) # ['h', 'o', 'n']Updating Items
Adding Items
Removing Items
Common Methods
Method
Purpose
List Comprehensions
Iteration
Last updated