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'.
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
Post a Comment