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)

25th Dec 2020, 4:45 PM
Meerim Jeembaeva
Meerim Jeembaeva - avatar
4 Antworten
+ 2
Meka , both strings "oa" and "Lol" give the expected output. So it works.
25th Dec 2020, 5:19 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 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"))
25th Dec 2020, 5:01 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
showing the same results
25th Dec 2020, 4:59 PM
Meerim Jeembaeva
Meerim Jeembaeva - avatar
0
nope, not really working
25th Dec 2020, 5:16 PM
Meerim Jeembaeva
Meerim Jeembaeva - avatar