The isinstance() method matches the specified object with the specified data type.
true if the object belongs to the same data typefalse if the object belongs to a different data typeYou can specify multiple types in the form of a tuple.
print("'Educative' is a string: ",isinstance("Educative", str))
In the example below, we have specified the int, float, and list as a data type. Since the object is a string, it returns false.
print("'Educative' is a string: ",isinstance("Educative", (int, float, list)))
We have created the class website and instantiated its object educative in line[4]. Later in this example, we verify its type:
class Website:domain = 'educative.io'Educative = Website()print("Educative is a website: ",isinstance(Educative, Website))
Free Resources