Shortcut to initialize variables

Leif K-Brooks eurleif at ecritters.biz
Sun Jun 19 12:46:50 EDT 2005


Kent Johnson wrote:
> letters = {}
> for letter in ascii_lowercase:
>  letters[letter] = 0

Or more simply:

letters = dict.fromkeys(ascii_lowercase, 0)



More information about the Python-list mailing list