[Tutor] More Pythonesque or a more efficient method

Kent Johnson kent37 at tds.net
Tue Oct 7 19:54:13 CEST 2008


On Tue, Oct 7, 2008 at 1:15 PM, Richard Lovely
<roadierich at googlemail.com> wrote:
> In a slightly related matter, Is is possible to use all() with a list
> comprehension to check if a word contains all of the letters of
> another?

Sure.

In [1]: all(letter in 'abcde' for letter in 'cde')
Out[1]: True

In [2]: all(letter in 'abcde' for letter in 'cdef')
Out[2]: False

Kent


More information about the Tutor mailing list