Is int()


#1



Here is the code I used:

def is_int(x):
if type(x)== int:
return True
else:
return False


Here is the error message:

Oops, try again. Your function fails on is_int(7.0). It returns False when it should return True.

How do i account for numbers like 7.0 being int when they are normally float?

Replace this line with your code.


#2

How do i account for numbers like 7.0 being int when they are normally float?

One way can be..
By checking decimal part of a number,If its zero then you'll return True.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.