1

I'm rather new to Python. I've coded this vowel counter:

str = "aeiou"
vowels = 0
for i in str:
  if (i=="a" or "e" or "i" or "o" or "u"):
     vowels = vowels+1
print("The number of vowels is:")
print(vowels)

but it's returning this:

The number of vowels is:
1
The number of vowels is:
2
The number of vowels is:
3
The number of vowels is:
4
The number of vowels is:
5

How can I get it to count all of the vowels at once and just provide the total (i.e. 5 in this case)

Radosław Cybulski
  • 2,952
  • 10
  • 21
Emma Wynne
  • 11
  • 1

0 Answers0