+ 1
Is there Any other Simple Solution??
Write a program that takes in a string as input, counts and outputs the number of vowels (A, E, I, O, U). Input Format: A string (letters can be both uppercase or lower case). Output Format: A number which represents the total number of vowels in the string.
3 Réponses
+ 2
you can simplify your code by defining vowels as
vowel = "aeiou"
(it does not need to be a list of individual characters)
and you do not need to sort the user_input.
+ 1
user_input = input().lower()
vowel =["a","e","i","o","u"]
text = sorted(user_input)
vowel_count = 0
for i in text:
if i in vowel:
vowel_count += 1
print(vowel_count)
0
#This was my simplest solution:
print(sum(char in 'aeiou' for char in input().lower()))