1) What do I need to do?
π― Your mission: Hero roll call
Make a list of 4 heroes. Use a for loop to print "Calling ___!" for each one.
2) What do I need to know?
for item in list
A for loop can walk through a list, giving you each item in turn.
for hero in team: β each time round, hero holds the next name.
π§° Your toolkit for this mission
Everything you need to know to finish this lesson on your own:
for item in list
Visit every item in turn.
How to write it: The loop variable holds the current item each time round.
for hero in team:
print("Calling", hero + "!")Running total
Add everything up.
How to write it: Make total = 0 before the loop, then total = total + item inside.
total = 0
for s in scores:
total = total + s
print(total)sum() / max() / min()
Built-in shortcuts for number lists.
How to write it: max(scores) gives the biggest, min the smallest, sum the total.
print(max(scores))
Think about it
Look at this code. What happens next, and why? Say it in your own words.
for hero in team:
print(hero)
print("Done")Watch & explore βΆ
Power-up: for item in list
See it happen
1 / 3team = ["Bolt", "Nova"] for hero in team:
The loop variable holds the first item.
3) Run the code & terminal output
Press βΆ RUN and your program's messages appear here!


Captain Py
Our next adventure is yours to create.
