Reputation: 1
I'm trying to print the the datatype of a value in string format.
When I use the str() function to do this it however still prints it as a type value.
data = str(type(4.5))
print(data , type(data))
OUTPUT: <class 'float'> <class 'str'>
The output I'm expecting OUTPUT: float <class 'str'>
Upvotes: 0
Views: 31
Reputation: 531055
You are looking for the __name__
attribute.
>>> type(4.5).__name__
'float'
Upvotes: 1