Remove Vowels
Remove English vowel characters from text with a loop. Students build a new result from nonmatches and preserve spaces, punctuation, and remaining letter order.
1# Take string input2s = input("Enter a string: ")34# Remove vowels5vowels = "aeiouAEIOU"6result = ""7for char in s:8 if char not in vowels:9 result += char1011print(f"Without vowels: {result}")
Output
Enter a string: Hello Without vowels: Hll
In this one
- Filter a listed character set
- Keep nonvowels in order
- Retain punctuation and spaces
How it works
- 1
Visit the input's characters.
- 2
Append char only when absent from vowels.
- 3
Print the new filtered string.
Edge cases
Are spaces removed?
Are spaces removed?
No. They are copied.
What if the input contains only listed vowels?
What if the input contains only listed vowels?
The result is empty.
What's going on
The vowel string contains both English cases. A character is appended only if it is not a member of that string.
For Hello!, the result is Hll!. No lowercase conversion is required because both cases are listed. Digits and spaces remain because they are not vowels. Accented characters and y also remain under this explicit vowel definition.
Are spaces removed? No. They are copied.
What if the input contains only listed vowels? The result is empty.
Quiz
Tap an option. The answer stays hidden until you pick.
Question 1
What does the condition select?
Pick an answer to check it.
Question 2
Are spaces removed?
Pick an answer to check it.
Questions people ask
Are spaces removed?
No. They are copied.
What if the input contains only listed vowels?
The result is empty.
What does the condition select?
Characters absent from the vowel set.
๐Related Content
- ๐
Phase 5 - Learn Concepts
Review Phase 5 concepts and explanations
- ๐
Phase 5 - Quiz
Test your Phase 5 understanding with quiz questions
- ๐ป
Phase 5 - All Practice Problems
Explore all practice problems for Phase 5
- ๐
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- ๐ง
Logic Building Overview
Learn about the complete logic building curriculum