Testing the data type of a value
ben.usenet at bsb.me.uk
Sun May 12 06:41:29 EDT 2019
binoythomas1108 at gmail.com writes:
> When I run the following code, I get the following output:
> 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'>":
> Why isn't this working? Advance thanks for your time.
See if this helps...
>>> type("<class 'int'>")
so you are comparing two things with different types. An analogous
situation would be to
and then to try to compare 5 with the earlier output by writing
if 5 == "5": ...
More information about the Python-list