Skip to Content
Learn
Hash Maps: Python
Defining the Getter

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.

Instructions

1.

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

2.

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

Return that value.

Folder Icon

Sign up to start coding

Already have an account?