Lesson 4 of 7
Lists: store lots of values
A list stores several values in a single variable: bag = [3, 7]. You add with bag.append(5).
len(bag) gives the number of items, and sum(bag) adds everything up at once.
bag = [1, 2] bag.append(3) print(len(bag)) # 3 print(sum(bag)) # 6
🎯 Your mission
Your bag holds bag = [3, 7] coins. Add 5 with append, compute total = sum(bag), then print total.
PRO lesson
This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.
Discover PRO →