thecodezone.
The Code Zone
Short steps, at your pace · Free lessons and practice · Member video walkthroughs
Save your next small win.

Checking your account…

03.04 · Loops / Practice · 8 min

Stop after finding the first vowel

The search found e, but it kept looking. Its final no-match message is now misleading.

Activity 4 of 8 in Loops

All courses

Python 2: Logic, Loops & Functions / 03.04

Practice a for else search

Not started

Repair a search that finds a vowel but keeps scanning and prints a no-vowels message.

More options

Your lesson progress

Walkthrough: not startedPractice: not started

Empty: not started. Yellow: in progress. Green: complete. Marking the whole activity complete does not replace your test results. These circles save in this browser for this pilot.

Rob scans team, highlights the first vowel e, and stops before the later letters a and m.
Rob’s comic strip · Loops

Your task: stop the successful search

Keep word assigned to team and vowels assigned to aeiou. Keep the existing found message and no-vowels message. Add the loop control needed to stop immediately after the first vowel is found.

For team, print Found a vowel! exactly once, stop with char holding e, and skip the loop else. Keep else aligned with for. Do not delete the no-vowels path; it is needed when no character matches.

Try the no-match and empty-word paths too

The fixed-input checks inspect the word, vowel characters, last visited character and complete output. They do not prove every other word or the algorithm used. After passing, try rhythm: expect No vowels found in the word. Try an empty word: expect the same no-vowels message without visiting a character.

Restore team before checking again. This beginner rule checks the lowercase vowels listed in vowels; uppercase letters are outside this task’s rule.

Build it one step at a time

Prefer learning by typing? Work through short instructions, run the Python code and check each change before continuing. Your guided project saves separately from the challenge below.

The mini-lesson opens in a new tab. Your own code carries forward; each step has a focused check and an optional hint.

Start mini-lesson(opens in a new tab)

3 steps · Saved work · Instant feedback

YOUR TURN

Stop at the first matching vowel

Keep word = "team" and vowels = "aeiou". Stop the search immediately after printing the first found message. Preserve the loop else for words with no matching lowercase vowel.

Expected output
Found a vowel!

Keep the starting inputs. Print these lines in this order, without extra output.

  • Keep word as team
  • Keep the lowercase vowel set
  • Stop with char at the first vowel e

Edit Python, then run it. Check challenge checks your output and the listed Python requirements. Your code saves on this browser after a short pause. Sign in and choose Save account draft to keep it across devices. Word wrap is enabled.

Ready to checkRun the checks to see your results here.

Need a nudge?

Finding a match should exit the search

break exits the loop and skips its else. Put it in the same if block as the found message, after that print.

Replace your editor code?

Your current work will be replaced. Choose Cancel to keep it.

Ready to try it?

Practice in your browser and see your results.

Progress details

Have a question?

Ask the Code Zone community.

Ask a question in The Code Zone (opens in a new tab)

Continue learning

ONE STEP FORWARD

The first match stops the loop and prevents its no-match else. Next, put one loop inside another.