FAQ: Hash Maps: Python - Handling Collisions in the Setter

Its amazing to me that this error was highlighted almost two years ago and it hasn’t been fixed. Does Codeacademy ever fix problems with their courses? I’ve found SO many problems here.


This is still an issue and makes this exercise very confusing. Please get this fixed, it should not be taking 1 year+ to fix the order of these instructions.

It’s not that hard guys. :grinning: :grinning:
Think this way,
In the conceptual part we read about different ways for handling collisions. If you remember, in the collisions section it was written that when we have same index values for multiple keys we store the key and value both at that particular index. That’s why it was written as [key, value]. It’s just a simple list with key stored at index 0 and value at index 1. You can also store it as [value, key]. It’s completely your wish but you would have to remember at what index you stored key and value to access them later on.
Also, in the if statement where we check if the keys are same it was written

if current_array_value[0] == key:
self.array[array_index] = [key, value]

It simply means we are checking if the key of key, value pair currently stored at that particular index is same to the key passed in the method or not. If it is equal then we know that same keys cannot have different value so we just reassign the value.
All the return statements are left blank to avoid using if/elif/else statement so that for any condition that is met the function stops there only without returning any value.
I think that this could have been kept more clear in the lesson but for now I think this explanation would do the work.
I think that would clear most of the questions. Ask me again if anything not clear. :slightly_smiling_face:

P.S. This is also explained in the very next exercise.

1 Like

This was extremely frustrating, figuring out that my code was correct, but that my problem was not having step 3 completed before step 2. I’m kind of surprised that this issue came up over a year prior to this post and it’s still the same. Just switch steps 2 and 3 and save future users an unnecessary headache.

It’s still the same because it’s not an issue. Read above. There is just lack of explanation.

I am not sure if its just for me but…
on the 3rd step even if you don’t wrote any code at all it will be accepted as you did correctly.