im trying to add to a dictionary that looks like the following
d = {"feline" : {"lion" : 22,
"tiger" : 88 },
"canine" : {"dog" : 12,
"wolf" : 53,
"coyote" : 77} }
im trying to add 'cat' and 55 to the dictionary under feline but im not sure how to acess this. this is what i attempted
fp = raw_input("enter a feline type")
apa = input("enter an amount")
for keys in d :
if fp not in d[keys] :
d['feline'] = {fp : int(apa)}
but when i do this the values such as tiger and lion get deleted and the input is replaced for them. for example if i want to add cat under the 'feline' section, usin the above code i get...
{'feline': {'cat ': 55}, 'canine': {'coyote': 77, 'wolf': 53, 'dog': 12}}
how do i keep lion and tiger in the dictionary without overwriting them using dictionaries