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
10 Answers
+ 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")
+ 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..
+ 1
I thought That I did by only telling the program the vowels
+ 1
Oh!
I forgot about thatđ
+ 1
Thanks!
+ 1
Ok
+ 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!
0
I mean the variable x
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.
0
you can change the print function to
print("you have ", z, " vowels")