Count the letters
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
This one builds on a lesson you haven't finished yet. Do that lesson first:
Python Basics · Counting loops →
Count the letters
word is "banana". Use a for loop to count its letters into n. Do not use len.
A counter lives outside the loop (so it is not reset every turn) and grows inside it. That shape — set up, loop, use — comes back constantly.
word is "banana". Use a for loop to count its letters into n. Do not use len.
Click Run to see the output here.