Access to key and value in a dictionary!


Hello together!
I have a dictionary with different values. For example:

wallet = {'Coins' : 4.75, 'Banknote' : 100}

for i in wallet():
print i

This just prints:

What I want is a print like:
Coins : 4.75
Banknote : 100

I've tried it with this:

for i, j in wallet:
print i, j

But I get an error that tells me "too many values to unpack"
I would like to understand how to access to both of them. I know that I can print just the whole dictionary, but it looks not like what I want!

I hope you can help me!


Hey guys!

Well I found a way how to print it like that!
Here is my solution!

for i in wallet:
print i, wallet[i]

Anyway - Thanks


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.