So I am trying to get a grasp on Hash Functions and how exactly they work. I have the following code but I keep getting an error when I try and run the code.
import sys def part_one(): foo = open('input_table.txt') for line in foo: id, make, model, year = line.split(",") print(make, model) tuple_list = (make+model,) return tuple_list def hash_one(num_buffers, tuple_list): #part_one() # A being the first constant prime number to multiply by # B being the prime number that we add to A*sum_of_chars tuple_list = part_one() A = 3 B = 5 count = 0 for item in tuple_list: for char in item: # sum_of_chars is the total of each letter in the word count = ord(char) count = count + tuple_list index = ((A * sum_of_chars + B)) % num_buffers return index if __name__ == '__main__': input_table = sys.argv[1] num_buffers = int(sys.argv[2]) chars_per_buffer = int(sys.argv[3]) sys.argv[4] = 'make' sys.argv[5] = 'model' lst = [] for item in range(4, len(sys.argv)): lst.append(sys.argv[item]) print(lst) hash_one(lst) What is wrong with my code that is causing the error? Can anyone help me?
errorthat you are receiving?