Is_int problem with printing


#1


https://www.codecademy.com/courses/python-intermediate-en-rCQKw/0/3?curriculum_id=4f89dab3d788890003000096

Code is correct

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

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


#2

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.


#3

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