[Tutor] Dict question
Daniel Coughlin
kauphlyn@speakeasy.org
Wed, 13 Jun 2001 16:59:58 -0700 (PDT)
> if error_dict.has_key(error):
> l = error_dict.get(error)
> l.append(error_ip)
> append = {error: l}
> error_dict.update (append)
> else:
> x = [`error_ip`]
> append = {error: x}
> error_dict.update (append)
>
if error_dict.has_key(error):
l = []
l.append(error_dict.get(error))
l.append(error_ip)
etc.
I've never used the get() before but it appears to return the value associated
with the key, which in this case is a string. You were then assigning that
string to l. In this case we declare l as a list first then append values to it.
That should work for you. (I didnt test it!)
Hope this helps!
Daniel