Until you type stop
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 · While loops →
Until you type stop
Read words one at a time until the word stop arrives, then report how many came before it.
Read the first word before the loop, so the condition has something to test. Inside the loop, count the word and then read the next one. When you press Run, type each word and press Enter.
Difficulty 3/5 · 200 coins + a small bonus on first completion today
Keep reading words with input() until the word is stop. Then print how many words came before stop. For the words cat, dog, stop, print 2.
Click Run to see the output here.