Coding and Decoding in Python

Wanderer wanderer at dialup4less.com
Thu Mar 17 11:52:44 EDT 2011


On Mar 17, 11:44 am, John Gordon <gor... at panix.com> wrote:
> In <2f4a08df-55ea-4a4e-9cc0-24e6b9f81... at f15g2000pro.googlegroups.com> Wanderer <wande... at dialup4less.com> writes:
>
> > But when the program returns the value I can't get the key.
>
> What happens when two keys have the same value?  How would you know which
> key to return?
>
> In your sample code all the values are different, but surely that won't
> always be the case with real data.
>
> --
> John Gordon                   A is for Amy, who fell down the stairs
> gor... at panix.com              B is for Basil, assaulted by bears
>                                 -- Edward Gorey, "The Gashlycrumb Tinies"

I guess two keys having the same value is why dictionaries don't
return keys for values, but this is a code. Each value has a unique
meaning to both sender and receiver. The text part is for making the
program understandable and printing understandable error messages.




More information about the Python-list mailing list