Syntax or indent errors


#1

Hi. So, I was messing around with the code and tried writing a simple if statement. It looked like this:

# Make sure that the_flying_circus() returns True
def the_flying_circus():
  age = raw_input("Are you a teenager? Lets find out! What is your age? ")
  
  status = "" #teenager or kid
  
if age >= 13:
      status = 'teenager'
      return not False
print "Yes! You are a %s!" % (status)

elif age < 13:
      status = 'kid'
      return False
print "No... you are a %s." % (kid)

else:
      return False
print "Whoops! You did something wrong."

There were multiple versions of this piece of code and none of them worked out like I wanted them to. Either I’d get an indent or syntax error. Can someone help me? Thanks in advance.


#2

Not asked for. The function can do anything but MUST return True, and must use the operators given.


#3

I know, bud. I did what the exercise wanted and got it right. I was just trying something different, but I get this error:

File "python", line 12
    elif age < 13:
       ^
SyntaxError: invalid syntax

I thought it was some whitespace issue but when I “fix” it I start to get this one:

 File "python", line 7
    if age >= 13:
    ^
IndentationError: unexpected indent

#4

The print statements are what’s messing this up. They should either be before the return line of after the if statement.


#5

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