Hi everyone.
I have a dictionary in dictionary created using dict() that looks like this:
There are thousands of item groups like these in the dictionary. I want to change the structure from a dictionary to a 3-column structure like this:
This is how I am trying to format it:
But it gives the error message "TypeError: unhashable type: 'dict'", for obvious reasons. Since I am a newbie, I don't know how to go about the problem. So is there any other way I could do this? Thanks.
I have a dictionary in dictionary created using dict() that looks like this:
Code:
Mobile {'Nokia': 15, 'Motorola': 6, 'HTC': 10}
Car {'red': 5, 'gray': 7, 'black': 13, 'white': 2}
Camera {'Canon':7, 'Sony': 5}
.
.
There are thousands of item groups like these in the dictionary. I want to change the structure from a dictionary to a 3-column structure like this:
Code:
Mobile Nokia 15
Motorola 6
HTC 10
This is how I am trying to format it:
Code:
for key in gitems.keys():
print key
for item in gitems.values():
print("\t\t{item:11}{number:11}".format(item=item, number=gitems[number]))
But it gives the error message "TypeError: unhashable type: 'dict'", for obvious reasons. Since I am a newbie, I don't know how to go about the problem. So is there any other way I could do this? Thanks.