+ 2
Trying Challenge to count vowels, but second test is failing can anyone tell me what's wrong?
Link: https://www.sololearn.com/coach/80?ref=app My Code: s = input() n = 0 for i in s: if i=='a' or i=='e' or i=='i' or i=='o' or i=='u': n+=1 print(n) Test question failing: Is there life on Mars? It's giving me 6 with my code but and should be 7! Can anyone help me here? What's wrong?
4 ответов
+ 6
BlackSpectrum ,
when you are counting vowels, make sure that also *uppercase* vowels are counting.
instead of checking each letter against the vowels, we can use the `in` operator like:
if letter.lower() in 'aeiou':
+ 2
Why not troubleshoot your code? If there is more than 1 vowel, what does you code do? What else could go wrong?
+ 2
BlackSpectrum ,
Thanks for putting the link to the task description in your question body.
+ 2
Lothar,
Thanks forgot about upper case, my bad