Chapters
Python114 chapters

ReferenceBuilt-in functions

type()

The class an object belongs to.

Signature

type(object)

Parameters

NameMeans
objectanything

Returns

A type object. .__name__ gives just the name.

Example

Python
print(type(5).__name__)
print(type("a").__name__)
print(type([]).__name__)
print(type(None).__name__)

Output

int
str
list
NoneType

See also