Skip to Content
Hash Maps: Python
Creating an Instance

Since we have the basic functionality of a hash map, let’s create a test instance of one for us to make sure everything works as expected.



Outside the HashMap class (completely unindented below the class definition) create a new hash map called hash_map. Give it an array size of 20.


We want to use this hash map to store geologic information — types of rocks.

In hash_map save the value "metamorphic" for the key "gneiss".


Now retrieve the value of hash_map for the key gneiss. Print it out, does your HashMap work as expected?

Folder Icon

Sign up to start coding

Already have an account?