I only just started using python 3.7 today and I copied some code from a youtube video, but there is a syntax error at my last elif and I don't exactly know why. I don't know whether my indentation is off or if there is something I don't see. Idk if you guys could show me some examples or fix my code for me that would be most appreciated!
This is just a little project off of youtube, but it just isn't working for me. I am using Visual Studio Code on a Mac, if that effects anything...
command = ''
started = False
while True:
command = input(">").lower()
if command == "start":
if started:
print("Car is already started!")
else:
started = True
print("Car started...")
elif command == "stop":
if not started:
print("Car is already stahhped!")
else:
started = False
print("Car stopped...")
elif command == "help":
print("""
start - car will start
stop - car will stop
quit - terminate the game!
"""
elif command == "quit":
break
else:
print("Sorry, I don't understand that...")
I keep on getting this error (this is for the last elif):
File "/Users/petes./Desktop/Python/CarGame.py", line 23
elif command == "quit":
^
SyntaxError: invalid syntax*emphasized text*
elif command == "help":
RépondreSupprimerprint("""
start - car will start
stop - car will stop
quit - terminate the game!
"""
elif command == "quit":
break
you can close the brackets before elif command =="quit":