Problems
The returns you have are not right:
return true
...
return false
True
and False
take the first capital letter. As it has gives execution error because neither true
nor false
exist.
This comparison is also not right:
v == ("a")("e")("i")("o")("u")
Here it is as if you were using "a"
as a function because it makes "a"("e")
. And so it does not compare with all the values as you would imagine. Maybe you wanted to do this:
if v == "a" or v == "e" or v == "i" or v == "o" or v =="u":
That although not very idiomatic would already work.
Solution
The simplest way is to use the in
operator by testing with a string that contains only the vowels. This makes your code very simple and easy to read:
def vogal (v):
if v in "aeiou": # aqui testa com o operador in
return True
else:
return False
Now it gives you the expected result:
print(vogal('e')) # True
print(vogal('b')) # False
See the code running on Ideone
You can even turn the function into a line, although this is usually a style for more experienced programmers:
def vogal (v):
return v in "aieou"
To also consider the uppercase, you simply enter them in string :
def vogal(v):
return v in "aeiouAEIOU"
Or use the lower
method to always convert the input to lowercase:
def vogal(v):
return v.lower() in "aeiou"