LOL - My homework was completed, however, I think it was by force rather than skill:
L4 Problem 10
(5/5 points)
Define a function isVowel(char) that returns True if char is a vowel ('a', 'e', 'i', 'o', or 'u'), and False otherwise. You can assume that char is a single letter of any case (ie, 'A' and 'a' are both valid).
Do not use the keyword in. Your function should take in a single string and return a boolean.
Is there a cleaner way of doing this?
L4 Problem 10
(5/5 points)
Define a function isVowel(char) that returns True if char is a vowel ('a', 'e', 'i', 'o', or 'u'), and False otherwise. You can assume that char is a single letter of any case (ie, 'A' and 'a' are both valid).
Do not use the keyword in. Your function should take in a single string and return a boolean.
Code:
def isVowel(char):
'''
char: a single letter of any case
returns: True if char is a vowel and False otherwise.
'''
if char == 'a' or char == 'e' or char == 'i' or char == 'o' or char == 'u' \
or char == 'A' or char == 'E' or char == 'I' or char == 'O'\
or char == 'U':
isVowel = True
else:
isVowel = False
return isVowel
Is there a cleaner way of doing this?