Logic Building
# Take string input
s = input("Enter a string: ")
# Count vowels
vowels = "aeiouAEIOU"
count = 0
for char in s:
if char in vowels:
count += 1
print(f"Number of vowels: {count}")Output
Enter a string: Hello Number of vowels: 2
Check each character if it's a vowel.
Key Concepts:
- Define vowel string
- Check if character in vowels
- Count matches