Skip to content

Python type function | Get object type

  • by

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 checking 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 or suggestions on this Python basic function tutorial.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

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

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading