+ 1

Please check. lam learning For loop in python

I created this code to check how many vowel letters are there in the word that user typed. But when I type capital letters it not working. What can I do? https://code.sololearn.com/cadT46m4hlik/?ref=app

3rd Oct 2020, 6:03 AM
roshan roy
5 Answers
+ 5
As already mentioned, you are on a good way with your code. some small improvements can be done: - make the code count lower and upper case letters (1) - use a better readable comparison to check whether the character is a vowel or not (2) - you can omit the conditional statement at the end of your code (3) word = input() count = 0 for x in word : if x.lower() in 'aeiou': #(1)(2) count += 1 print("The word contains " + str(count) + " vowel letter.")
3rd Oct 2020, 9:03 AM
Lothar
Lothar - avatar
+ 4
Hey, congratulations! You are doing a good job, it's ok if your code is not perfect right now, you'll improve in the way. """ Please use this section when you have specific issues, doubts with your code. Otherwise your post will be considered as some kind of advertisement. You can share your progress in your personal feed. """ Edit: Thanks for editing the post. Now it's clear that you really need help. https://www.sololearn.com/discuss/1316935/?ref=app
3rd Oct 2020, 6:25 AM
Kevin ★
+ 3
In case if you input capital letters it won't count capital vowels so convert all letters in lower case and then check. Suggestion- You could remove if (for count==1) and else condition and can only use one print statement 😊
3rd Oct 2020, 6:11 AM
SOUMYA
SOUMYA - avatar
+ 1
If you input any capital vowels the code doesn't count it. Idk python but find a way to ignore the letter case. E.g. aeiou == 5 AEIOU == 0
3rd Oct 2020, 6:16 AM
Odyel
Odyel - avatar
0
it is not counting the uppercase since you are only checking for lower case. either first convert x to be lower case, or also include upper case vowels in your if statement
3rd Oct 2020, 10:11 AM
John Doe