| Python Lists | |
| Lists in Python are ordered, mutable sequences. You can create a list using square brackets: | |
| my_list = [1, 2, 3, 4, 5] | |
| Adding Items: | |
| - Use append() to add one item: my_list.append(6) | |
| - Use extend() to add multiple items: my_list.extend([7, 8, 9]) | |
| - Use insert() to add at specific position: my_list.insert(0, 0) | |
| Accessing Items: | |
| - Use indexing: my_list[0] gets first item | |
| - Use slicing: my_list[1:3] gets items 1 and 2 | |
| - Negative indexing works: my_list[-1] gets last item |