Access to key and value in a dictionary!


#1

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:
Coins
Banknote

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!


#2

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


#3

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