0
Regular Expressions , strings
it should return true if the given object is a vowel ( a, e, i, o, u), and otherwise false? My code is not working for all of the strings, I don't understand why? My code errors: For example : Input "Lol", Output: False. But it should be True, because it has vowel. My code: oa, when double vowels, also didn't worked import re def is_vowel(s): pattern = r'([AEIOUaeiou])' match = re.findall(pattern, s) if match: return (True) else: return (False)
4 Answers
+ 2
Meka , both strings "oa" and "Lol" give the expected output. So it works.
+ 1
Meka , remove the brackets "()". You can try this ->
import re
def is_vowel(s):
pattern = r'[AEIOUaeiou]'
match = re.findall(pattern, s)
if match:
return (True)
else:
return (False)
print(is_vowel("oa"))
0
showing the same results
0
nope, not really working