0
Why it’s printing True even I put a float value like with zero after decimal point - for example (7.0 , 5.0) ?
def is_int(x): if x == int(x): return True else: return False print(is_int(5.0)) print(type(5.0)) Please explain it! Thank You in advance.
1 Resposta
+ 3
Because python evaluates 5.0 == 5 as true despite the difference in type.
Try this instead:
if type(x) == int: