I’m learning Python 3.
My code
numbers = [1, 2]
print( type( numbers[0] ))
outputs
<class ‘int’>
How do I print only
‘int’
or
int
I’m learning Python 3.
My code
numbers = [1, 2]
print( type( numbers[0] ))
outputs
<class ‘int’>
How do I print only
‘int’
or
int
You can use the __name__
attribute from the type.
>>> type(5).__name__
'int'
Or without using the type built-in:
>>> (5).__class__.__name__
'int'