The Big If


#1



Oops, try again.
the_flying_circus() returned the value None, did you forget to add a return statement?


name = raw_input("What is your name?")
age = raw_input("How old are you?")
def the_flying_circus():
    if (len(name) > 8 and age > 14):
        return True
    
    elif (len(name) < 8 and age < 14):
        return False
        
    else:
        print ("Please type a string")


#2

Hello

You did not add a return statement after else.
If has one, elif has one, but else not.
The error "did you forget to add a return statement?"

Hope that helps. Let me know.


#3

My code isn't working on "The Big If".
Here's my code:

def the_flying_circus():
if 3 < 4 and 6 < 7:
return True
elif:
return True
else:
return False

And here's the error message:

Oops, try again. An exception was raised while running your code, see the console window for the error message.

File "python", line 7
elif:
^
SyntaxError: invalid syntax

I would really appreciate some help. Thanks!


#4

Hello

The instructions are -

def the_flying_circus():
if condition:
# Do something!
elif condition:
# Do something else!
else:
# Do yet another thing!

Did you notice that you have not done the full instructions?

Just remember that if you have a question, to create your own topic. It is easier to help you that way.
It can become rather difficult and confusing because not all answers will relate to the original topic. And you might get advice which was actually meant for another user's topic. Coding can be confusing, so we do not want create more confusion.

Hope that helps.


#5

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