The big if weird issue


#1

https://www.codecademy.com/en/courses/python-beginner-BxUFN/4/1?curriculum_id=4f89dab3d788890003000096

My code works but it won't print a statement I made, even tho it returns True so it should

def the_flying_circus():
    hamed_is_immature = True
    if (3 >= 4) and (False or False) == True:   
        return True
    elif (4 >= 3) and (hamed_is_immature != False):
        return True 
        print ('Hamed is Immature')
    else:
        print ( (4 * 4 * 4 * 4 ^ 2) * (4))
        return False

Tell me why it returns true but it won't print. I checked to make sure it wasn't the first statement being true and it isn't. someone please help


#2

The return keyword in Python stops execution of the function at that point and returns the result, so it will never reach the print ('Hamed is Immature') line. You can fix this making sure any code you wish to execute is above the return True line.


#3

Tried this

def the_flying_circus():
    hamed_is_immature = True
    if (3 >= 4) and (False or False) == True:   
        return True
    elif (4 >= 3) and (hamed_is_immature != False):
        print ('Hamed is Immature')
        return True
    else:
        print ( (4 * 4 * 4 * 4 ^ 2) * (4))
        return False

still nothing


#4

You'll also have to invoke the function at the bottom of the script:

def the_flying_circus():
    hamed_is_immature = True
    if (3 >= 4) and (False or False) == True:   
        return True
    elif (4 >= 3) and (hamed_is_immature != False):
        print ('Hamed is Immature')
        return True
    else:
        print ( (4 * 4 * 4 * 4 ^ 2) * (4))
        return False

the_flying_circus()

Hopefully that should fix the issue you're having!


#5

you know what, I have no idea why that worked but it did! Thank you!


#6

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