You are given an input how do you get the number of vowels in the the input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

You are given an input how do you get the number of vowels in the the input

How many vowels

14th Aug 2021, 11:03 AM
TroyxHunter
12 Answers
+ 8
1. Make a list of vowels. 2. Make a counter variable to count the amount of vowels. 3. Iterate through the given string and check if a character is in the list you made - if so, add 1 to your counter.
14th Aug 2021, 11:08 AM
Yahel
Yahel - avatar
+ 6
TroyxHunter , please don't ask the community to do this job for you. to get ready codes does not really help you to progress in learning and it does not develop your problem solving ability. as you have joined sololearn just some days ago, it looks like this is a homework or a challenge like this. thanks for your understanding!
14th Aug 2021, 1:51 PM
Lothar
Lothar - avatar
+ 5
Buddy, Yahel gave you the best hint you'll get for this simple excersize. And Abhay straight up GAVE YOU the answer. Why should any more of us help you when you don't even want to help yourself?
14th Aug 2021, 11:28 AM
Slick
Slick - avatar
+ 1
#If a is a string of vowels. a="aeiouAEIOU" #b is a string to find vowels into. b="abhay" #you can maintain a counter variable , count=0 #now iterate through the string , for i in b: #and check if character i is in string a. if i in a: count+=1
14th Aug 2021, 11:17 AM
Abhay
Abhay - avatar
0
TroyxHunter How about using the sum() method? :- print(sum(True for x in input().lower() if x in "aeiou")) # It's a generator expression that yields 'True' if the character is a vowel. The sum() function counts the occurrence by converting it into an int (1 here). # Hope this helps # Happy coding!
14th Aug 2021, 5:26 PM
Calvin Thomas
Calvin Thomas - avatar
- 2
Ok that looks ok let me tey
14th Aug 2021, 11:19 AM
TroyxHunter
- 2
Try sorry
14th Aug 2021, 11:19 AM
TroyxHunter
- 2
Ok now l have got the answer
14th Aug 2021, 11:28 AM
TroyxHunter
- 4
No didn't work
14th Aug 2021, 11:23 AM
TroyxHunter
- 5
Come on that is not helping
14th Aug 2021, 11:11 AM
TroyxHunter
- 5
Send me code l see
14th Aug 2021, 11:13 AM
TroyxHunter
- 5
Anybody else
14th Aug 2021, 11:24 AM
TroyxHunter