Skip to main content

Hash Map

# Creating a hash table to store fruits based on their first letter
hash_table = {}
hash_table['A'] = 'Apple'
hash_table['B'] = 'Banana'
hash_table['O'] = 'Orange'

# Accessing a fruit based on its first letter
print(hash_table['A'])  # Output: 'Apple'
print(hash_table['B'])  # Output: 'Banana'
print(hash_table['O'])  # Output: 'Orange'