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.11 LAB: The continue statement - the Pretty Vowel Eater

 3.2.1.11 LAB: The continue statement - the Pretty Vowel Eater

the Pretty Vowel Eater
The Pretty Vowel Eater

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

Objectives

Familiarize the student with:

using the continue statement in loops;

modifying and upgrading the existing code;

reflecting real-life situations in computer code.

Scenario

Your task here is even more special than before: you must redesign the (ugly) vowel eater from the previous lab (3.1.2.10) and create a better, upgraded (pretty) 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;

assign the uneaten letters to the word_without_vowels variable and print the variable to the screen.

Look at the code in the editor. We've created word_without_vowels and assigned an empty string to it. Use concatenation operation to ask Python to combine selected letters into a longer string during subsequent loop turns, and assign it to the word_without_vowels variable.

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

Test data

Sample input: Gregory

Expected output:

GRGRY

Sample input: abstemious

Expected output:

BSTMS

Sample input: IOUEA

Expected output:

Solution Code

word_without_vowel = ""
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:
        word_without_vowel += letter
        
print(word_without_vowel)

In below video, we will see how for loop works. We started with an empty variable word_without_vowel to use it later to combine the letters which are NOT VOWELS. 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

A new thing which is word_witout_vowel += letter which adds or combines the letter which has not exempted/not vowels to be printed in the console as one word


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

Follow the Python page on the Blog to be the first to know

Understanding the continue Statement

The continue statement is a control-flow tool used inside loops. When Python reaches continue, it immediately skips the rest of the current iteration and jumps back to the top of the loop for the next item. This is different from break, which ends the loop entirely. The distinction is central to this Lab, which combines a loop with conditions that decide when to skip an iteration.

In this exercise you process the letters of a word, and the goal is to select or output only certain characters. Using continue lets the loop examine each character but skip over the ones that do not meet the condition, so the output ends up showing only the desired letters. Reading the scenario and test data carefully tells you exactly which characters should be kept and which should be skipped, and therefore where the continue should be placed.

continue vs. break

  • continue skips the rest of the current iteration and moves to the next one.
  • break immediately exits the entire loop without executing any further iterations.
  • Choosing the right one depends on whether you want to ignore a single item or stop the whole process.

Key Takeaways

  • continue skips only the current iteration of a loop.
  • Placing continue after the condition that should be filtered keeps the correct characters flowing to the output.
  • Filtering characters in a word is a common pattern that combines a loop, an if, and continue.
  • Work through the test data by hand to confirm exactly which characters the loop keeps.

Frequently Asked Questions

What does continue do in Python?

Inside a loop, continue stops the current iteration and begins the next one, skipping any remaining code in that iteration.

Why would I use continue instead of an if statement?

Both can express filtering logic. continue is convenient when you want to skip the rest of a long body for certain inputs without nesting everything in an if, which can make the code easier to read.

Does continue work in both for and while loops?

Yes. continue behaves the same in for and while loops: it moves straight to the next iteration's condition or item.

Comments

Popular Posts

PROJECT MAVEN | The Architecture of Algorithmic Warfare

Open Source: The Invisible Engine of Your Daily Life

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

Python 4.3.1.10 LAB: Converting fuel consumption

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