Welcome to Chapter 5: Lists! 📝
💡 Think of it like this: A list is like a shopping list — it's an ordered collection of items. You can add items, remove items, change items, and look at specific items by their position.
Common list operations:
.append(item) — Add an item to the end.remove(item) — Remove a specific item.pop() — Remove and return the last item.sort() — Sort the list in orderlen(list) — Get how many items are in the list# Creating a list fruits = ['apple', 'banana', 'cherry'] # Accessing items (index starts at 0!) print(fruits[0]) # apple print(fruits[1]) # banana print(fruits[-1]) # cherry (last item)
Run your code
['eggs', 'milk', 'bread', 'rice', 'butter']
eggs
butter
5