Back

Lists and Dictionaries

Lists are ordered collections. Dictionaries store key-value pairs. These are Python's most used data structures.

# List
fruits = ["apple", "banana", "cherry"]
fruits.append("mango")
fruits.remove("apple")
fruits[0]  # "banana"

# Dictionary
user = {
    "name": "Daniel",
    "age": 20,
    "skills": ["Python", "JavaScript"]
}
user["name"]          # "Daniel"
user["city"] = "Dallas"  # add new key
user.get("email", "N/A") # safe access with default

Roadmap