32
loading...
This website collects cookies to deliver better user experience
fruits={"Apple":100,"Orange":50,"Grapes":40}
print("The fruits dictionary is ", fruits)
stock_quantity={fruits:20}
print("The stock quantity of fruits", stock_quantity)
The fruits dictionary is {'Apple': 100, 'Orange': 50, 'Grapes': 40}
Traceback (most recent call last):
File "c:\Projects\Tryouts\Python Tutorial.py", line 3, in <module>
stock_quantity={fruits:20}
TypeError: unhashable type: 'dict
fruits=tuple({"Apple":100,"Orange":50,"Grapes":40})
print("The fruits tuple is ", fruits)
stock_quantity={fruits:20}
print("The stock quantity of fruits", stock_quantity)
The fruits tuple is ('Apple', 'Orange', 'Grapes')
The stock quantity of fruits {('Apple', 'Orange', 'Grapes'): 20}
fruits={"Apple":100,"Orange":50,"Grapes":40}
print("The fruits dictionary is ", fruits)
price={"fruits_price":fruits}
print("The price for each fruits are ", price)
The fruits dictionary is {'Apple': 100, 'Orange': 50, 'Grapes': 40}
The price for each fruits are {'fruits_price': {'Apple': 100, 'Orange': 50, 'Grapes': 40}}