How to print only datatype in Python

Viewed 192

The output for type(10) is int. The output for print(type(10)) is <class 'int'>.

Is there a way of printing only the datatype in Python?

1 Answers

You can get the __name__ attribute of the class:

print(type(10).__name__)

Output:

int
Related