Back to Lessons
Advanced

Custom __len__ on a Bag ([12, 22, 32, 42])

Give a Bag class __len__. Fill it with [12, 22, 32, 42] and print len(bag).

Part of CodeAscent Premium

Your first 10 lessons are free. Unlock every beginner, intermediate, and advanced lesson — and keep your streak going — with a subscription. Start with a 7-day free trial.

$4.99/month or $39.99/year after trial. Cancel anytime.