I would like to append a value to a dictionary key where there is already a
value. Something like the below:

d = {'name': {'2': 0.0, '7': 10.0, '8': 0.0, '9': 0.0}}
append 10 to d['name']['2']
d = {'name': {'2': 0.0,10, '7': 10.0, '8': 0.0, '9': 0.0}}

When I try to this I get the following error:
>>> d['name']['2'].append(10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'float' object has no attribute 'append'

I am obviously doing this wrong. How would I accomplish this?

Thank you in advance.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to