What is the isinstance() method in Python?

The isinstance() method matches the specified object with the specified data type.

  • It returns true if the object belongs to the same data type
  • It returns false if the object belongs to a different data type

You can specify multiple types in the form of a tuple.

Code

Single data type

print("'Educative' is a string: ",
isinstance("Educative", str))

Multiple data types

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)))

User-defined types

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))
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved