There is a natural expectation after placing an item into a bag that we will later be able to remove the item from that bag. Otherwise we have created a hole. Let’s implement retrieval for our hash map.



Define a .retrieve()method for HashMap. It should take two parameters: self and key.


.retrieve() should calculate the array index in the same way our .assign() does and then retrieve the value at that index.

Return that value.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?