0
You are given an input how do you get the number of vowels in the the input
How many vowels
12 Antworten
+ 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.
+ 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!
+ 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?
+ 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
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!
- 2
Ok that looks ok let me tey
- 2
Try sorry
- 2
Ok now l have got the answer
- 4
No didn't work
- 5
Come on that is not helping
- 5
Send me code l see
- 5
Anybody else