2
ini={"MAIN":{}}
ini['MAIN']['Nome']="Jaque"
print ini
Print output: {'MAIN': {'Nome': 'Jaque'}}
How to put a new dictionary into what already exists?
I want to have it: {'MAIN': {'Nome': 'Jaque'} 'NOVO_DICT': {} }
2
ini={"MAIN":{}}
ini['MAIN']['Nome']="Jaque"
print ini
Print output: {'MAIN': {'Nome': 'Jaque'}}
How to put a new dictionary into what already exists?
I want to have it: {'MAIN': {'Nome': 'Jaque'} 'NOVO_DICT': {} }
0
I believe you want to have it:
{'MAIN': {'Nome': 'Jaque'}, 'NOVO_DICT': {}} #vígula antes de 'NOVO_DICT'
If I’m right, so just add a new value to the entry NOVO_DICT
of the variable ini
. Thus:
ini={"MAIN":{}}
ini['MAIN']['Nome']="Jaque"
ini['NOVO_DICT']={}
print ini
In assigning {}
at the entrance NOVO_DICT
of the variable ini
, Python automatically already creates this entry if it does not exist.
that’s right! Thanks
Browser other questions tagged python dictionary
You are not signed in. Login or sign up in order to post.
Would not be
ini['NOVO_DICT'] = {}
? I couldn’t quite understand the doubt.– Woss
Or else
ini.update( { 'NOVO_DICT':{} } )
.– AlexCiuffa