+ 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.

18th Dec 2024, 1:51 PM
HASAN IMTIAZ
HASAN IMTIAZ - avatar
3 ответов
+ 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.
18th Dec 2024, 2:23 PM
Lisa
Lisa - avatar
+ 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)
18th Dec 2024, 1:51 PM
HASAN IMTIAZ
HASAN IMTIAZ - avatar
0
#This was my simplest solution: print(sum(char in 'aeiou' for char in input().lower()))
18th Dec 2024, 2:38 PM
Brian
Brian - avatar