The use of type()
rosuav at gmail.com
Sun Feb 10 16:49:25 EST 2019
On Mon, Feb 11, 2019 at 8:46 AM ^Bart <gabriele1NOSPAM at hotmail.com> wrote:
> I need to print something like "this variable is int" or "this variable
> is string"
> n1 = 10
> n2 = 23
> print ("Total of n1+n2 is: ",n1+n2," the type is", type(n1+n2))
> When I run it I have:
> Total of n1+n2 is: 33 the type is <class 'int'>
> I'd like to read "the type is int" and NOT "the type is <class 'int'>,
> how could I solve it?
Many things in Python, including functions and types, have inherent names.
>>> print(sys.__name__, int.__name__, print.__name__)
sys int print
More information about the Python-list