> ###
> >>> d = {}
> >>> def addTally(name):
> ... d.setdefault(name[0], []).append(name)
> ...
> >>> addTally('john')
> >>> addTally('brian')
> >>> addTally('jane')
> >>> addTally('alice')
> >>> addTally('bob')
> >>> d
> {'a': ['alice'], 'j': ['john', 'jane'], 'b': ['brian', 'bob']}
> ###
>
>
> Here, we can see that the key 'john' can be associated with multiple
> values.
Hi James,
Quick typo correction. I meant to write:
"""Here, we can see that the key 'j' can be associated with multiple
values."""
My apologies!
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor