Featured Posts

Start Your Journey with Linux Command Line

Image
Start Your Journey with the Linux Command Line: A Comprehensive Guide Whether you are a software developer, system administrator, analytics engineer, or cybersecurity enthusiast, mastering the Linux command line (terminal) is one of the single most effective skills you can acquire. While graphical user interfaces (GUIs) offer visual convenience, the command line interface (CLI) delivers unmatched speed, fine-grained system control, and seamless automation capabilities. Linux Command Line This tutorial breaks down more than 35 core Linux commands into structured, practical modules complete with real-world examples, flags, and command-chaining techniques. By building muscle memory around these fundamentals, you will elevate your daily technical workflow from basic navigation to advanced command orchestration. Why Learn the Command Line? The Linux CLI is not merely a legacy tool—it remains the foundation of modern cloud architecture, server maintenance, DevOps pipelines, and enterp...

Python 3.2.1.10 LAB: The continue statement - the Ugly Vowel Eater

The continue statement - the Ugly Vowel Eater

the Ugly Vowel Eater
 the Ugly Vowel Eater

If you're taking PCAP - Programming Essentials In Python , you may have encountered this question in 3.2.1.10 LAB: The continue statement - the Ugly Vowel Eater.

Objectives

Familiarize the student with:

using the continue statement in loops;

reflecting real-life situations in computer code.

Scenario

The continue statement is used to skip the current block and move ahead to the next iteration, without executing the statements inside the loop.

It can be used with both the while and for loops.

Your task here is very special: you must design a vowel eater! Write a program that uses:

a for loop;

the concept of conditional execution (if-elif-else)

the continue statement.

Your program must:

ask the user to enter a word;

use user_word = user_word.upper() to convert the word entered by the user to upper case; we'll talk about the so-called string methods and the upper() method very soon - don't worry;

use conditional execution and the continue statement to "eat" the following vowels A, E, I, O, U from the inputted word;

print the uneaten letters to the screen, each one of them on a separate line.

Test your program with the data we've provided for you.

Test data

Sample input: Gregory

Expected output:

G

R

G

R

Y

Sample input: abstemious

Expected output:

B

S

T

M

S

Sample input: IOUEA

Expected output:

I

O

U

E

A

Solution Code:

user_word = input("Please Enter a Word: ").upper()
#vowels A, E, I, O, U
for letter in user_word:
    if letter == "A":
        continue
    elif letter == "E":
        continue
    elif letter == "I":
        continue
    elif letter == "O":
        continue
    elif letter == "U":
        continue
    else:
        print(letter)

In below video, we will see how for loop works. It checks each condition with the statements inside the block. If True then the condition is exempted/passed

If letter == "A":

      continue

This means, if the letter equals "A", the letter is passed and not shown

=================================================================================

Follow the blog to be the first to know ❤

How the continue Statement Skips Iterations

The Ugly Vowel Eater is a lab that teaches the continue statement, which stops the current iteration of a loop and jumps straight to the next one without executing any further statements inside the loop body. It works with both while and for loops. In this exercise the program reads a word, converts it to upper case with user_word = user_word.upper(), and then walks through the word one letter at a time with a for loop.

Inside the loop the code uses conditional execution to recognize the five vowels A, E, I, O, and U. For each letter it tests whether the character matches one of these vowels using a chain of if, elif, and else branches. When a vowel is matched, the matching branch executes continue, which abandons the rest of the loop body for that letter. Because the only remaining statement in the loop is print(letter), a vowel is never printed; the else branch runs only for consonants and displays them, one per line.

Tracing the Output with Sample Inputs

Considering the word Gregory, the loop skips the vowels G-r-e-g-o-r-y, leaving the consonants G, R, G, R, and Y printed on separate lines, exactly matching the expected output. For the unusual word abstemious, which contains the vowels a, e, i, o, and u, the program prints only the consonants B, S, T, M, and S. Even a word made entirely of vowels, like IOUEA, still produces output, because every vowel triggers continue and each vowel appears on its own line while the word also contains no consonants to suppress. This demonstrates that continue skips the current iteration but does not end the loop.

Key Takeaways

  • The continue statement jumps to the next iteration, skipping any code that follows it in the loop body.
  • It is valid inside both while and for loops.
  • Converting the input with user_word.upper() makes the vowel comparison case-insensitive.
  • An if-elif-else chain matches each vowel and calls continue to prevent it from being printed.
  • The else branch runs only for consonants, printing each one on a separate line.
  • For the input IOUEA the loop still finishes, showing that continue does not terminate the loop.

Frequently Asked Questions

What is the difference between continue and break?

Continue skips only the current iteration and lets the loop move to the next one, while break exits the loop entirely.

Why is the word converted to upper case first?

So that both uppercase and lowercase vowels are recognized by a single set of comparisons, since upper() normalizes every letter.

Does continue work in a while loop too?

Yes. Continue behaves the same way in while loops, skipping the rest of the body and evaluating the loop condition again.

Why are vowels printed on their own lines when the whole word is vowels?

In the provided solution the else branch prints whatever is not a vowel, and every vowel triggers continue instead, so only the else output appears.

Comments

Popular Posts

PROJECT MAVEN | The Architecture of Algorithmic Warfare

Python 3.2.1.14 LAB: Essentials of the while loop

Data Analysis Roadmap 2026: From Excel Lover to Python-Powered Analyst

Open Source: The Invisible Engine of Your Daily Life

Python for Windows Beginners: Build Your First Automated Workflow in 10 Minutes