Python Practice Mode - Dictionaries

Screen Link:

My Code:

my_dict = {}
for i in range(len(keys)):
    my_dict[keys[i]] = values[i]

What I expected to happen:
Nice Work!

What actually happened:

“my_dict isn’t defined in your code, but we expected it to be dict type”

1 Like

I did run your exact code and it was accepted. Can you refresh the console and try again?

1 Like

I did . Now it is accepted but after many refreshes. I get also same type of errors from the next problems in the section. After a few refreshes my solutions are accepted…

1 Like

Must be some technical glitch. Maybe @Sahil can guide you if the problem persists.

1 Like

How can I communicate with him ? The problem does persists

1 Like

Please raise a support ticket by clicking on the question mark icon on the top right side of the mission screen.

1 Like

Your code works.

However, you don’t need to create range and a for loop to iterate keys and values.

Use zip to iterate (keys[i], values[i]) tuple at each index i. No object is created, zip uses iterators to access each paired values. The number of paired tuple (keys[i], values[i]) = length of whichever is shorter (keys or values.) You can use print(list(zip(keys, values))) to see what zip does.

my_dict = dict(zip(keys, values))
1 Like

Hi @konteas17giannis,

Sorry about that, this is a known issue:

However, it is strange for the error to persists after reloading the page. Can you try doing a hard refresh?

1 Like