Editor

Print Without Vowels

Beginner · Write the code · from Python break, continue, pass: Controlling Loop Flow

From the lesson: Python break, continue, pass: Controlling Loop Flow

You're searching through a phone book for your friend's number. Once you find it, do you keep flipping through every remaining page? Of course not - you stop. Or imagine you're reading a list of emails. You skip the spam and only read the real ones. These are everyday examples of controlling the flow of a loop.

Read the lesson

Use a for loop with continue to print all the characters in the string "beautiful", but skip the vowels (a, e, i, o, u). Print each consonant on the same line using end="".

Expected output:

btfl

Don't forget to print an empty print() at the end for a clean newline.

word = "beautiful"
# Print each character, but skip vowels using continue
print() # newline at the end

More break, continue, pass exercises

All Python exercises · 50 practice problems · Control Flow quiz