Python type function | Get object type

Python type function is used to get the type of object. This function with one argument, return the type of an object. The type() function is mostly developers use it for debugging purposes.

Syntax

type(object, bases, dict)

Note: The isinstance() function is recommended for check the type of an object because it takes subclasses into account.

Example type function in Python

Simple example code.

a = ('a', 'b', 'v')
b = "Hello World"
c = 100

print(type(a))
print(type(b))
print(type(c))

Output:

Python type function

Do comment if you have any doubts and suggestions on this Python basic function tutorial.

Note: IDE: PyCharm 2021.1.3 (Community Edition)

Windows 10

Python 3.7

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.