Blossom Project: NameError

I am getting this error
Traceback (most recent call last):
File “”, line 7, in
class HashMap:
File “”, line 37, in HashMap
blossom = HashMap(len(flower_definitions))
NameError: name ‘HashMap’ is not defined

from linked_list import Node, LinkedList

from blossom_lib import flower_definitions

class HashMap:

def init(self,size):

self.array_size = size

self.array = [LinkedList() for i in range(size)]

def hash(self,key):

return sum(key.encode())

def compress(self,hash_code):

return hash_code % self.array_size

def assign(self,key,value):

array_index = compress(self.hash(key))

#self.array[array_index] = [key,value]

payload = Node([key, value])

list_at_array = self.array[array_index]

for index in list_at_array:

  if key == index[0]:

    index[1] = value



def retrieve(self,key):

array_index = compress(self.hash(key))

list_at_index = self.array[array_index]

#if payload != None and payload[0] == key:

  #return payload[1]


  #return None

if key == index[0]:

  return index[1]


  return None

blossom = HashMap(len(flower_definitions))

for flower in flower_definitions:

blossom.assign(flower[0], flower[1])


Hello, @adityabahubali,

In order for users to be able to help you, they need to examine the indentation of your Python code. Since portions of your code have not been correctly formatted for posting, those users cannot view that indentation effectively. Please see How to ask good questions (and get good answers) for information regarding how to format code for posting.

In some, but not all cases, a NameError results when lines of code are unintentionally indented, making them part of code blocks where they should not have been included. This is because the scope in which a name becomes defined determines where that name is recognized within a program.

Edited on October 31, 2020 to add the following:

Link to project page: Hash Maps: Blossom