Thanks to all for the responses.
Problem solved!, and I get a lot of valuable info.
Thanks
Emilio
- Mensaje original
> De: Alan Gauld
> Para: tutor@python.org
> Enviado: lunes, 11 de mayo, 2009 1:59:32
> Asunto: Re: [Tutor] How to control the not existent ke
2009/5/10 Emilio Casbas :
>
> Hello,
>
> I have some problems testing keys not existent in a dictionary.
> The code works testing existent keys with his corresponding value, but
> If I enter a not existent key, an exception is raised.
> How can I control the not existent key and assign him a defaul
"Emilio Casbas" wrote
If I enter a not existent key, an exception is raised.
How can I control the not existent key and assign him a default value?
One way is to use the get() method of a dictionary:
d = {'Exists': True}
d['Exists']
True
d['Error']
Traceback!!!
d.get('Error',Fal
On 5/10/2009 3:48 PM Emilio Casbas said...
Hello,
I have some problems testing keys not existent in a dictionary.
The code works testing existent keys with his corresponding value, but
If I enter a not existent key, an exception is raised.
How can I control the not existent key and assign him a
Hello,
I have some problems testing keys not existent in a dictionary.
The code works testing existent keys with his corresponding value, but
If I enter a not existent key, an exception is raised.
How can I control the not existent key and assign him a default value?
u...@cipher:~/project/progra