Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

closed It says that there is a syntax error, but I don't know why.

+11 votes
asked Nov 21, 2021 by Christopher Clark (220 points)
closed Feb 21 by Admin
if building_1 == "2":

print("You walk into the building.".center(150))
closed with the note: answered

2 Answers

+2 votes
answered Nov 22, 2021 by Peter Minarik (58,190 points)

Generally, it is a good idea to share

  • the whole code of yours, not just a single line as the problem could originate from before
  • what the exact error message is

Without knowing what exactly is going on, I'd say that you need to indent the print as it belongs to the if statement's body.

Another problem could be building_1 is not being a string or could be of some other type that's not comparable to a string.

Nothing else could be told without knowing more.

+1 vote
answered Dec 8, 2021 by ManavPatni (200 points)

if building_1 == "2":

print("You walk into the building.".center(150))

It is an invalid syntax because you have not given proper intentation it should be like:

if building_1 == "2":

        print("You walk into the building.".center(150))

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...