Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I'm making a python text adventure game, and I'm getting an error with the choice system I made

so I’m making a python "choose your own adventure" text game. and the choice system is outputting a confusing error, I’m fairly new to python, and my question is most likely silly and an easy fix, but I don’t get it. my error is an invalid syntax error, the speccific error is File "main.py", line 17 elif answer == "b": ^ SyntaxError: invalid syntax
my code is

import os
import random
room = random.randrange(100,400)
print("                                    --------THE HOTEL--------")
answer = input("                                   < Press enter to continue >")
print("You enter the hotel, its storming outside")
print("the receptionist, a girl with black hair and brown eyes says hi to you.")
print("Your reserved room is number",room) 
print("  ")
answer = input("(A): Thanks!                                                                                                     (B): Your cute                                                                                                                          (C): ...")
os.system('clear')
if answer == "a":
   print("You: Thanks!")
   print("no problem!")
   
   elif answer == "b":

I know it has something to do with my if/elif statements I don’t know if I was supposed to turn the elif into an if or not, but I can’t figure it out.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The elif statement should have the same indentation as the if statement above.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading