I have a python dictionary which is described below:
dict={
"Moli": {"Buy": 75, "Sell": 53, "Quantity": 300}
"Anna": "Buy": 55, "Sell": 83, "Quantity": 154}
"Bob": {"Buy": 25, "Sell": 33, "Quantity": 100}
"Annie": {"Buy": 74, "Sell": 83, "Quantity": 96}
}
I want to select or print first item's sub-value (i.e: "Buy": 75
) of this nested dictionary.
If I am using this code:
print(trading_portfolio[(list(trading_portfolio.keys())[0])]["Buy"])
I'm getting error like this:
select first item from this nested dictionary
builtins.KeyError: "Buy"