binoythomas1...@gmail.com writes:

> When I run the following code, I get the following output:
>>>> print(type(5))
> class 'int'
>
> Next, I try to compare the data-type of 5 with the earlier output, I
> get no output:
>>>> if type(5) == "<class 'int'>":
>         print("Integer")
>
> Why isn't this working? Advance thanks for your time.

See if this helps...

>>> type(5)
<class 'int'>
>>> type(type(5))
<class 'type'>
>>> type("<class 'int'>")
<class 'str'>

so you are comparing two things with different types.  An analogous
situation would be to

>>> print(5)
5

and then to try to compare 5 with the earlier output by writing

  if 5 == "5": ...

-- 
Ben.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to