Re: simple question about dictionaries

2008-07-22 Thread Bruno Desthuilliers
skazhy a écrit : hi, i am new to python, so i've a really simple question about dictionaries. if i have a dictionary and I make have an input after it (to input numbers) can i get the key of value that was in input? What if many keys are associated with a same value, ie: d = {'a

Re: simple question about dictionaries

2008-07-22 Thread Jeff
On Jul 21, 8:14 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Jeff wrote: > >   throw KeyError('%s not found' % str(val)) > > "throw"?  and shouldn't that be a ValueError? ;-) > > Whoops. Been working in too many different languages at the same time :). -- http://mail.python.org/mailman/listinf

Re: simple question about dictionaries

2008-07-22 Thread Jeff
On Jul 21, 8:14 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Jeff wrote: > >   throw KeyError('%s not found' % str(val)) > > "throw"?  and shouldn't that be a ValueError? ;-) > > Whoops. Been working in too many different languages at the same time :). -- http://mail.python.org/mailman/listinf

Re: simple question about dictionaries

2008-07-21 Thread Fredrik Lundh
Jeff wrote: throw KeyError('%s not found' % str(val)) "throw"? and shouldn't that be a ValueError? ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: simple question about dictionaries

2008-07-21 Thread Jeff
On Jul 21, 7:35 am, skazhy <[EMAIL PROTECTED]> wrote: > hi, i am new to python, so i've a really simple question about > dictionaries. > if i have a dictionary and I make have an input after it (to input > numbers) can i get the key of value that was in input? > >

Re: simple question about dictionaries

2008-07-21 Thread Fredrik Lundh
skazhy wrote: hi, i am new to python, so i've a really simple question about dictionaries. if i have a dictionary and I make have an input after it (to input numbers) can i get the key of value that was in input? A dictionary contains (key, value) pairs, and is optimized for quickly fi

Re: simple question about dictionaries

2008-07-21 Thread Berco Beute
Sounds like a school assignment. Find the answer yourself here: http://diveintopython.org/toc/index.html You'll learn a lot more in the process. 2B -- http://mail.python.org/mailman/listinfo/python-list

simple question about dictionaries

2008-07-21 Thread skazhy
hi, i am new to python, so i've a really simple question about dictionaries. if i have a dictionary and I make have an input after it (to input numbers) can i get the key of value that was in input? somehting like this: dict = { "key1"=100,"key2"=200,"key3"