Reputation: 103
Currently I have a nested dictionary with keys as "Apple" and "Mango". and in the value we have "0" again as keys.
Fruits = {
"Apple": {
"0": 0.066
},
"Mango": {
"0": 0.933
}
}
instead I wish it to look like :
Fruits = {
"Apple": 0.066
,
"Mango": 0.933
}
Upvotes: 0
Views: 133
Reputation: 1545
Fruits = {
"Apple": {
"0": 0.066
},
"Mango": {
"0": 0.933
}
}
new_fruits = {}
for fruit, values in Fruits.items():
new_fruits[fruit] = values["0"]
print(new_fruits)
output:
{'Apple': 0.066, 'Mango': 0.933}
Upvotes: 1