📚
Leçon 13 · classe P2
Lists & dicts: real-life data
📖 Leçon
──▶
🎯 Quiz — choisis la traduction
──▶
✅ Leçon terminée
A list is a box with ordered slots: shopping = ["milk", "bread", "apples"]. A dict is an address book: phone = {"Mum": "+49 151…"} — the name gives the number instantly.
- ●liste[0] → first element (counting starts at 0!)
- ●liste.append("cheese") → append at end
- ●phone["Mum"] → Mum's number
- ●for entry in liste: → loop through all
Kapnula itself is lists and dicts: a city's listings = a list of dicts {title, price, photo}. Your quiz from the last project? Also a list!
💡 Task: create friends = {"name": "hobby"} for three friends and print nicely: for name, hobby in friends.items(): print(name, "—", hobby)
🎯
Teste-toi !
Quiz — choisis la traduction →
🖨 Fiche de travail
Consolide le sujet avec l’entraîneur — comme après le cours