I am a totally new programmer, learning python for the first time so sorry if my question isn't very clear and I am not using the correct computer science terminology. What I am trying to do is count the number of vowels in an inputed sentence without having to write out:
if i== 'a' or i == 'e' or i == 'i' or i == 'o' or i == 'u' or i == 'A' or i == 'E' or i == 'I' or i == 'O' or i == 'U'`
How do I check if the character char is inside the string 'aeiouAEIOU' using only one line? Could someone please tell me what am I doing wrong here?
This is my code so far.
def count_vowels (sentence):
vowels = 0
for char in sentence:
if char == 'aeiouAEIOU'.split():
vowels += 1
return vowels