+ 3

Hello world

I tried to solve the vowel counter but I didn't get a result. The question was for example "Sololearn is fun to learn". The problem is write a program to count the number of vowels in the example

9th Oct 2022, 4:48 PM
Lotus Robe
10 odpowiedzi
+ 4
str=input() n=0 for j in str: #compare with uppercase and lowercase if (j=='a' or j=='e' or j=='i' or j=='o' or j=='u' or j=='A' or j=='E' or j=='I' or j=='O' or j=='U'): n=n+1 print(n) Try this it works...
10th Oct 2022, 7:03 AM
Venkatesh
Venkatesh - avatar
+ 4
s = input() count = 0 for x in s: if(x == 'a','e','i','o','u'): count += 1 print(count) The attempt it counts the whole characters instead of the aeiou Help me out
9th Oct 2022, 5:11 PM
Lotus Robe
+ 4
Use in operator to check like this x in ['a','e','i','o','u']
9th Oct 2022, 5:23 PM
Prabhas Koya
+ 2
Lotus Robe 'a','e','i','o','u' is a tuple. You're comparing each letter with this tuple, what will be always false Since there are multiple vowels, it makes no sense to compare with equality. You should test if each letter is present in the set of vowels. The operator which does that is 'in'. Like: number in [1, 3, 7] Checks if number is one of 1, 3 or.7. Additional hint: a set of characters (the vowels) can be specified as a string.
10th Oct 2022, 12:55 AM
Emerson Prado
Emerson Prado - avatar
+ 2
x = input() a= ["a", "e", "i", "o","u","A","E","I","O","U"] b= [] for c in x: if c in a: b.append(c) print(len(b)) This also a easy method
11th Oct 2022, 3:57 PM
Venkatesh
Venkatesh - avatar
+ 1
Or like this x=='a' or x=='e' or x == 'i' or x=='o' or x== 'u'
9th Oct 2022, 5:24 PM
Prabhas Koya
+ 1
Prabhas Koya Arun Venkatesh.N I think you can benefit from my answer to Lotus Robe . Pls check it out. But an important advice: pls don't give finished code as answer, because it makes the OP skip the most important part of learning process. Prefer giving hints for the OP to find the solution. This allows for real learning.
10th Oct 2022, 9:20 AM
Emerson Prado
Emerson Prado - avatar
+ 1
Arun Venkatesh.N Pls consider my last answer to you
11th Oct 2022, 5:30 PM
Emerson Prado
Emerson Prado - avatar
0
Go na
11th Oct 2022, 2:33 PM
Abhishek Adatrao
Abhishek Adatrao - avatar