What can be key of a dictionary?

Key of a dictionary can be :
  • String
  • Numbers
  • tuples
  • List can’t be a key of a dictionary and also tuple of list can’t be same. If we assign a tuple of list as key then it will generate a TypeError: unhashable type: 'list'.

Comments

Popular posts from this blog

What is composite key?

What are the different data types in Python?

What is __repr__ function?