Python hash() Function

Returns the hash value of the specified value if it has one. Numbers do not have a hash value other than the number itself. Hash values are used to improve the performance of key lookups, for example in a dictionary.

Syntax

Python
hash(object)

Parameters

ParameterDescription
object Required. The object for which the hash should be generated.

Example

Python
print(hash(1))
print(hash('Hello World'))

Output

1
-7449866412269572252