All lessons
🗂️

Lists & Dictionaries

Organize collections of values efficiently.

Data Structures 15 min +50 XP

List

An ordered, mutable collection. Access items by index (0-based).

fruits = ["mango", "apple", "banana"]
print(fruits[0])   # mango
fruits.append("kiwi")

Dictionary

A collection of key-value pairs. Access values by key.

me = {"name": "Ali", "age": 19}
print(me["name"])
me["age"] = 20

Useful methods

Lists: append, remove, sort, len. Dicts: keys, values, items, get.

Functions