dododips
dododips

Reputation: 91

How to print only datatype in Python

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?

Upvotes: 2

Views: 743

Answers (1)

RJ Adriaansen
RJ Adriaansen

Reputation: 9619

You can get the __name__ attribute of the class:

print(type(10).__name__)

Output:

int

Upvotes: 3

Related Questions