This forum is now read-only. Please use our new forums! Go to forums

banner
Close banner
0 points
Submitted by Nelson Calado
over 8 years

Syntax error on question 17/19

When I run the code:

 def shut_down(s): 
    return s
 if (s) == "yes":
    return "Shutting down"
    elif (s) == "no":
        return "Shutdown aborted"
    else:
        return 'Sorry'

it returns a syntax error:

File "python", line 6
    elif (s) == "no":
       ^
SyntaxError: invalid syntax

I’ve tried multiple variations and consulted other posts, but with no luck. Do have any suggestions? Thank! :)

Answer 55df0db3d3292f5a4400011e

0 votes

Permalink

Never mind. The correct code is:

def shut_down(s):

    if s == "yes":
        return "Shutting down"
    elif s == "no":
        return "Shutdown aborted"
    else:
        return "Sorry"
points
Submitted by Nelson Calado
over 8 years

2 comments

Brau over 8 years

I had the same problem and I saw your post, thanks for posting the correction

Samuel.Wiltshire.17 over 8 years

Same issue, but it was because i’m a twonk who can’t get out of old coding habits. I forgot that you need two = signs in python, not one.