Is_int problem with printing


Code is correct

Console doesn't print 'True' or 'False'

def is_int(x):
    if x % 1 == 0:
        return True
        print 'True'
        return False
        print 'False'


a function ends the moment a return keyword is reached, so it never reaches print.

i would instead add print to the function call:

print is_int(-5.3)

This way, you print what the function returns

I like your solution, its clever.


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