compare dictionaries

Paul Rubin no.email at nospam.invalid
Tue Sep 7 23:56:07 CEST 2010


Baba <raoulbia at gmail.com> writes:
>         for k in word.keys():
>             if k not in hand:
>                 return False
>             elif k in hand:
>               if word[k] > hand[k]:
>                   return False
>         return True

Untested:

all(word[k] <= hand.get(k,0) for k in word)



More information about the Python-list mailing list