Count Vowels in a String
Loop aur membership test se string me vowels count karo.
Working code
text = "BrounStack"
vowels = "aeiou"
count = 0
for char in text.lower():
if char in vowels:
count += 1
print(count)Expected output
3How it works
String ko lowercase karke har character check hota hai. Character aeiou me ho to counter increment hota hai.
Try Yourself
text = "Programming"
vowels = "aeiou"
count = 0
for char in text.lower():
if char in vowels:
count += 1
print(count)