Remove Vowels

Remove all vowels from string.

IntermediatePhase 5 - Category 2: Character OperationsExample 9 of 10
remove-vowels.py
1# Take string input
2s = input("Enter a string: ")
3
4# Remove vowels
5vowels = "aeiouAEIOU"
6result = ""
7for char in s:
8 if char not in vowels:
9 result += char
10
11print(f"Without vowels: {result}")

Output

Enter a string: Hello
Without vowels: Hll

What's going on

Build new string excluding vowels.

Key Concepts:

Check if character not in vowels
Add to result if not vowel
Build new string