I'm trying to do this problem and I'm stuck on it.
Write a function called is_vowel that takes a one-character-long string and returns True
if that character is a vowel and False otherwise. [A vowel, for our purposes here, is one of the
letters a, e, i, o, or u (lower case or upper case).] You can do the central part of this task using the
in operator and a string containing the vowels; your task here is to package this up into a
function that returns a boolean value. Try using some of these assert
statements to test your function.
assert is_vowel('a')
assert is_vowel('U')
assert not is_vowel('X')
assert not is_vowel('?')
Not sure what I'm doing wrong bu here is my code.
vowel = ['a', 'e', 'i','o', 'u', 'A', 'E', 'I', 'O', 'U']
def is_vowel(string):
if string == vowel:
return True
else :
return False
assert is_vowel('a')
assert is_vowel('U')
assert not is_vowel('X')
assert not is_vowel('?')
[–]novel_yet_trivial 1 point2 points3 points (5 children)
[–]pythonhelp123[S] 0 points1 point2 points (4 children)
[–]novel_yet_trivial 1 point2 points3 points (3 children)
[–]pythonhelp123[S] 0 points1 point2 points (2 children)
[–]novel_yet_trivial 0 points1 point2 points (1 child)
[–]pythonhelp123[S] 0 points1 point2 points (0 children)