Using tuples to eliminate multiple dict values

Benshep ben.r.shepherd at gmail.com
Fri Sep 16 14:47:43 EDT 2011


I need a dictionary that returns the same value for multiple keys.

i.e.

(1)   >>> dict = { (1,2,3) : 'text' , (5,6,7) : 'other text' }
(2)   >>>dict[1]
(3)   'text'

I cant figure out what i need on line 2 to make this scenario work. Is
there a simple way to check if the a number is present in the key and
then return the value?

Thanks



More information about the Python-list mailing list