b0bbybtch
b0bbybtch

Reputation: 41

how to print words that only contain letters from a string?

I am trying to find all words from a text file(that I have turned into a list in python)that are made up of letters contained within a randomised string of vowels and consonants

Upvotes: 0

Views: 53

Answers (1)

Guillaume
Guillaume

Reputation: 1879

What about:

[w for w in words if set(w) == set(random_str)]

Upvotes: 1

Related Questions