0

[solved] I need help please

This code should output the number of vowels you have in your input but instead it outputs the number of letters all together: https://code.sololearn.com/cPrDGcV7I8gN/?ref=app

4th Jun 2022, 3:37 AM
Jonathan Cuppen
Jonathan Cuppen - avatar
10 Antworten
+ 3
😁print("vowels")😅 would not magically do that. something like this: vowels = "AaEeIiOoUu" y = input() z = 0 for letter in y: if letter in vowels: #👈 this... z += 1 print ("you have:") print (z) print ("vowels")
4th Jun 2022, 5:53 AM
Bob_Li
Bob_Li - avatar
+ 2
you only counted the letters, that's why it outputs that. you have to set a condition to tell the program which letters are vowels and count only those. That is the main purpose of the exercise..
4th Jun 2022, 3:42 AM
Bob_Li
Bob_Li - avatar
+ 1
I thought That I did by only telling the program the vowels
4th Jun 2022, 5:28 AM
Jonathan Cuppen
Jonathan Cuppen - avatar
+ 1
Oh! I forgot about that😅
4th Jun 2022, 6:03 AM
Jonathan Cuppen
Jonathan Cuppen - avatar
+ 1
Thanks!
4th Jun 2022, 6:04 AM
Jonathan Cuppen
Jonathan Cuppen - avatar
+ 1
Ok
4th Jun 2022, 6:08 AM
Jonathan Cuppen
Jonathan Cuppen - avatar
+ 1
It works fine? I think your code is awesome so, i so I put it in my bit and added allll credit to you!
4th Jun 2022, 6:15 PM
Hrithika Reddy
Hrithika Reddy - avatar
0
I mean the variable x
4th Jun 2022, 5:55 AM
Jonathan Cuppen
Jonathan Cuppen - avatar
0
Jonathan Cuppen That is another thing. Avoid using the same variable name for different things. first you assigned x a string of vowels x ="aAeEiIoOuU" then you used x as an iterator for the input for x in y this just breaks down each letter of y and assign it to x temporarily. No comparison is done here. Those are different. Plus, you did not actually compare each letter of the input to the vowels string. I renamed x to vowels. Hope it is clearer.
4th Jun 2022, 6:01 AM
Bob_Li
Bob_Li - avatar
0
you can change the print function to print("you have ", z, " vowels")
4th Jun 2022, 6:07 AM
Bob_Li
Bob_Li - avatar