Practice makes perfect - is integer



Can you help me understand this tip:
‘If the difference between a number and that same number rounded is greater than zero, what does that say about that particular number?’

does it mean? e.g. 3 - 3.0 = 0 == 0 this is integer => return True; 3 - 2.9 (which is rounded 3) = 0.1 != 0 This is not integer => return False

Kind Regards,

Python - Practice Makes Perfect - Hitting a Wall!

The thing here is that I don’t know how to express the float numbers different from .0.
So far I have come up with:

def is_int(x):
  if x - x != float or x - x == 0:
      return True
    return False

This show the error: " Your function fails on is_int(-3.4). It returns True when it should return False. "

If anyone could give me a tip on this task, would be very appreciated!


x - x will always give zero, how is that comparison helping?

yes, you understood that right :slight_smile:


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