0
I made a composite dictionary (Keys and Values) of alchemists of the anime Fullmetal Alchemist Brotherhood with the following keys: Nickname and patent and wanted to know how to erase the patent key along with its values of all alchemists stored in that dictionary.
alquimistas = {'Edward Elric': {'Alcunha': 'Alquimista de Aço', 'Patente': 'Major'},
'Alex Louis Armstrong': {'Alcunha': 'Alquimista dos Punhos Poderosos', 'Patente': 'Major'},
'Roy Mustang': {'Alcunha': 'Alquimista das Chamas', 'Patente': 'Coronel'},
'Isaac McDougal': {'Alcunha': 'Alquimista de Gelo', 'Patente': 'Major'},
'Basque Grand': {'Alcunha': 'Alquimista de Sangue e Ferro', 'Patente': 'General de Brigada'},
'Giolio Comanche': {'Alcunha': 'Alquimista de Prata', 'Patente': 'Major'},
'Shou Tucker': {'Alcunha': 'Alquimista da Trama Vital', 'Patente': 'Major'},
'Solf J. Kimblee': {'Alcunha': 'Alquimista Rubro', 'Patente': 'Major'},
'Tim Marcoh': {'Alcunha': 'Alquimista de Crista', 'Patente': 'Major'}
}
print (alquimistas)
That one
nome
came from where?– user141036
when you iterate on an object you can extract the
indice
of each iteration; i.e.nome
will always be the name of the alchemist– RFL
Returns nothing
– user141036
put a code test for you to see the result
– RFL
Missed putting the
print (alquimistas)
why the code did not return anything.– user141036
You can remove the patent key of only one alchemist?
– user141036
yes @Alexf. use the
del
as I showed in the reply:del alquimistas['Edward Elric']['Patente']
– RFL
Would have to put
for 'Edward Elric' in alquimistas:
 del alquimistas['Edward Elric']['Patente']
?– user141036
Let’s go continue this discussion in chat.
– RFL