Python6 min read
Python Lists
Store multiple items in lists and manipulate them.
Emily Davis
December 18, 2025
0.0k0
Store multiple items together.
Creating Lists
```python cities = ["Miami", "Austin", "Denver"] numbers = [1, 2, 3, 4, 5] mixed = ["apple", 10, True, 3.14] ```
Accessing Items
```python cities = ["Miami", "Austin", "Denver"]
print(cities[0]) # Miami (first item) print(cities[1]) # Austin print(cities[-1]) # Denver (last item) ```
Modifying Lists
```python fruits = ["apple", "banana"]
Add items fruits.append("orange") print(fruits) # ['apple', 'banana', 'orange']
Remove items fruits.remove("banana") print(fruits) # ['apple', 'orange']
Change item fruits[0] = "grape" print(fruits) # ['grape', 'orange'] ```
List Methods
```python numbers = [3, 1, 4, 1, 5]
numbers.sort() # Sort ascending print(numbers) # [1, 1, 3, 4, 5]
numbers.reverse() # Reverse order print(numbers) # [5, 4, 3, 1, 1]
print(len(numbers)) # 5 (length) ```
Remember
- Lists start at index 0 - Lists are mutable (can change) - Use append() to add items
#Python#Beginner#Lists