Check references

Report a typo

Create a function check(obj1, obj2) that compares two objects to determine if they refer to the same object in memory, regardless of their content or type. This is different from comparing their values or checking if they're equal.

Specification:

  1. The function should take two parameters: obj1 and obj2.

  2. The function should print:

    • True if obj1 and obj2 refer to the exact same object in memory.

    • False if obj1 and obj2 refer to different objects, even if they have the same value or content.

Note:

  • The comparison should work for any type of object (integers, strings, lists, custom objects, etc.).

  • You're checking for object identity, not equality of values.

  • The function should print the specified values, not return them.

Write a program in Python 3
def check(obj1, obj2):
...
___

Create a free account to access the full topic