Looping over a dictionary


#1

can any one help me to solve this program?


#2

I would think you could print a dynamic statement,

print key, d[key]

#3

in dictionary keys are 'a', 'b', 'c', values are 'apple', 'berry', 'cherry'

i had understood that
print key gives a, b, c
how d[key] gives values. could u plz explain?


#4

Dictionaries are made up of key-value pairs. The key is the object reference for the member, the value is the subscript reference.

d['a'] == 'apple'

#5

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