vendredi 15 mai 2020

how to consolidate an if-statement with multiple conditions in python 3.8?

I'm trying to take a list of words and print out another list of every word that has all 5 written vowels 'aeiou'.

print([word for word in word_list if 'a' in word and 'e' in word and 'i' in word and 'o' in word and 'u' in 
word])

For example, 'equation', 'consequential', and 'authorize' would be in the output list.

How can I consolidate all the conditions in the if-statement?

Aucun commentaire:

Enregistrer un commentaire