import re
def vocales(text):
#with regular expression.
print re.findall("[aeiouÁÉÍÓÚ]", text.lower(), re.IGNORECASE)
#or verifying letter by letter
print [e for e in text if e in "aeiouÁÉÍÓÚ"]
#Shows the characters that are not vowels
print [e for e in text if e not in "aeiouÁÉÍÓÚ"]
#Returns false if it has vowels
return not len([e for e in text if e in "aeiouÁÉÍÓÚ"])
vocales("Hola mundo. Hello world")
Выход:
['o', 'a', 'u', 'o', 'e', 'o', 'o']
['o', 'a', 'u', 'o', 'e', 'o', 'o']
['H', 'l', ' ', 'm', 'n', 'd', '.', ' ', 'H', 'l', 'l', ' ', 'w', 'r', 'l', 'd']
False