CodeAgeBy Sitezack
Python for Builders — Level 4Functions and lists0 XP
Chapter progress0/6

Lesson 5 of 7

Find the best score

To find the biggest value in a list, start with best = 0 and compare each item: if it's bigger, it becomes the new best.

That's the "champion pattern": every value challenges the reigning champion.

best = 0
for s in [4, 9, 2]:
    if s > best:
        best = s

🎯 Your mission

Here are your guild's scores: scores = [12, 45, 23, 38]. Find the best one with a loop and a variable best, then print best.

PRO lesson

This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.

Discover PRO