I'd like to reverse my key and value in a dict
. Item numbers are created as QTreeWidgetItem
, and dataBlock#
s are the data object for the item number.
my_dict = { dataBlock1:item1, dataBlock2:item2, dataBlock3:item3}
inv_dict = {v:k for k,v in my_dict.items()}
I got the error:
TypeError: unhashable type: 'QTreeWidgetItem'
How do I reverse the key & value in this case. I need item numbers as keys in the inv_dict
for another use purpose.