Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python id() function returns a unique id of the specified object. The id is the memory address of the object and it changes every time the program is executed. The id of an object is unique and constant during it's lifetime. Two objects with non-overlapping lifetimes may have the same id() value.

Syntax

id(object)

Parameters

object Required. Specify object like string, number, list and class etc.

Example:

In the below example, the id() function returns the unique id of list called MyList and it's elements. These ids gets changed every time the program is executed.

MyList = [10, 'Python']

print(id(MyList))

print(id(MyList[0]))
print(id(MyList[1]))

The output of the above code will be:

140437121242248

94259487597280

140437121126728

❮ Python Built-in Functions