Practice makes perfect 3/15

def is_int(x):
  if abs(x) - int(abs(x)) > 0:
    return True
    return False

This is the code i am trying here, can anyone please explain why is not working


if abs(x) - int(abs(x)) > 0:, do you understand what this line does?

if the value is greater then 0, it means you have a decimal value (other then 0), so False should be returned, yet you return True


yeah i realised my mistake as i was working on it. thanks


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