Count Vowels in String Python

What you want can be done quite simply like so:

>>> mystr = input("Please type a sentence: ")
Please type a sentence: abcdE
>>> print(*map(mystr.lower().count, "aeiou"))
1 1 0 0 0
>>>

In case you don’t know them, here is a reference on map and one on the *.

Leave a Comment