def simple_hash(key, table_size): total = sum(ord(char) for char in key) return total % table_size print(simple_hash('apple', 10)) # e.g. 6 print(simple_hash('banana', 10)) # e.g. 3
Click Run to execute this code.