Code is working. Just want to know if condition is sufficient to determine if number is integer.

Please specify any loopholes if any

```
def is_int(x):
if x-round(x)==0:
return True
else:
return False
```

Code is working. Just want to know if condition is sufficient to determine if number is integer.

Please specify any loopholes if any

```
def is_int(x):
if x-round(x)==0:
return True
else:
return False
```

It works for all values of x, greater or less than zero. No loopholes or edge cases. We can have it return a boolean without literally writing an if..else statement:

`return x - round(x) == 0`

```
>>> def is_i(x):
return x - round(x) == 0
>>> is_i(3.0)
True
>>> is_i(3.1)
False
>>> is_i(-3.0)
True
>>> is_i(-3.1)
False
>>>
```

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