why does this code not work and gives back (TypeError: 'str' object does not support item assignment
) :
sharesOwned = {'name': 'Apple.inc', 'symbol': 'AAPL', 'price':110, 'name': 'Google', 'symbol': 'GOOGL', 'price':330, }
for share in sharesOwned:
shareNow = {'name': 'WrongApple.inc', 'symbol': 'WrongAAPL', 'Wrongprice':10}
share['priz"'] = shareNow['name']
print (share['priz'])
How do we correctly assign from one dict to another?