Can you please help!


I have two quick questions about the attached screenshot:

  1. why does the answer in (see screenshot) look have
    for key in my_dictionary.keys()
    Specifically I’m looking at both of the “keys” in the line.
    I thought we were talking about the values (b/c we were adding ten).
    So I wrote something like:
    for value in my_dictionary.values()
    Why do we use key in both instances instead of value?

  2. In the next line why do we use
    my_dictionary[key] += 10
    Because we were talking about a dictionary I mistakenly used {}
    I actually made it:
    my_dictionary{values} again because I though we were seeking the value instead of the key.

Can you please advise?

Thank you in advance!


For more info the question itself asks: " The function should add 10 to every value in".
That’s part of why I used “value” over and over instead of “key”.

Thank you again!

You should post the code and the URL to the exercise in your post.

Hey there Josh :grinning:

Using .values() to add 10 to each number does not permanently change the dictionary:

a = {1: 10, 2: 20, 3: 30}
for value in a.values():
  value += 10

#prints {1: 10, 2: 20, 3: 30}

To manipulate the actual dictionary you have to refer to the value by its key

a[1] += 10
#prints 20
1 Like

try to add print statements everywhere and see what’s happening


This is an exceptional explanation. Thank you very much 8-bitgaming!

1 Like