14/19 - "Looping over a dictionary"


#1

I’ve been staring at this one since yesterday and I just have no idea what to do. I can’t think of anything in my notes so far that might help, and the hint didn’t point me in the right direction.
Instructions and hint:


Initial state of the code:

d = {'a': 'apple', 'b': 'berry', 'c': 'cherry'}

for key in d:
  # Your code here!

I just need to be pointed in the right direction. I would have thought print d[key] might be enough to solve the exercise, but it was not.


#2

You’re almost there.

key, d[key]

#3

Thank you. I would not have thought to do that. It looks simple now that I’ve seen the solution, but print key, d[key] did not even enter my thoughts.

Again, thank you.

Edit, 2018-07-10: I’m going back and doing all of these again, and this one stumped me (again). I came to see what I posted here, because I remembered it stumping me, and I saw the solution before solving the problem (again). Once again, I’ve proceeded past this exercise without understanding it and I feel very frustrated.


#4

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