+ 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
9 Answers
+ 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...
+ 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
+ 4
Use in operator to check like this x in ['a','e','i','o','u']
+ 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.
+ 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
+ 1
Or like this
x=='a' or x=='e' or x == 'i' or x=='o' or x== 'u'
+ 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.
+ 1
Arun Venkatesh.N Pls consider my last answer to you
0
Go na