← Python Programming
Collections and functions · 15 MIN

Lists and list operations

Lists and list operations

Lists are mutable ordered collections. Indexing starts at zero; slicing selects a range. append adds one item, extend adds multiple items, and sort changes the list in place. Avoid modifying a list while iterating over it unless you understand the effect.

Try it yourself

Change the example, run it, and explain the result in your own words. Then create one variation of your own.

Key idea

Use the example as a starting point, not something to memorize. Practise, inspect the result and make small improvements.

Code example

topics = ["HTML", "CSS"]
topics.append("Python")
print(topics[0], topics[1:])