Working with data
with data▶ 8:24
Use lists and dictionaries to work with a real dataset.
1 def summarize(records): 2 totals = {} 3 for name, minutes in records: 4 totals[name] = totals.get(name, 0) + minutes 5 return totals 6 7 today = [("reading", 45), ("coding", 90)] 8 print(summarize(today))
› python lesson.py
{ "reading": 45, "coding": 90 }
✓ Process finished
Follow the lesson, write the code, and build something of your own with help from AI that understands what you’re learning.
Use lists and dictionaries to work with a real dataset.
1 def summarize(records):
2 totals = {}
3 for name, minutes in records:
4 saved = totals.get(name, 0)
5 totals[name] = saved + minutes
6 return totals
Design a course in Academy, bring lessons to life in Creator Studio, and launch them with GTM.
Meet CS101, our hands-on introduction to computer science. Start with Python and build your first API.
Get Learn and Educator for Windows. Add hosted AI with OutClass Plus.
Free Windows desktop
Personal AI providers may charge separately.
Get the free appsC$12 / month
Test checkout collects no real payment.
See the AI preview