3/15 I really don't get these... Looking for a little help/motivation


I don’t even have code

def is_int(x):
  if float(x) >0:
    return True
    return False


So where did this code come from?


This was my base code…
By “not having any code”, I meant I did not have any code that really pertained to the problem


Not sure I follow your logic,

if float(x) > 0


I thought float checked to see if it was a decimal or not


A float can be any number, even an integer, as in 1.0. Our program should be able to identify that as an integer since it has no decimal value.

One simple check to follow up on is divisibility by unity (1).

if x % 1 == 0

When x % 1 is greater than zero, the number is not an integer.


Thank you, this is what I needed


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