Ask coding questions

← Back to all posts
Business Tycoon
launcherman08 (21)

Hi, I'm building a game in python, and I need it to write some code at the beginning. (It has a save feature, so yeah.) And I get this error:
Can I have some help?

Answered by HarperframeInc (454) [earned 5 cycles]
View Answer
HarperframeInc (454)

The Issue

On line 31 in

commands_displ = colored("COMMANDS:

You are missing an end quote " and a end parenthesis )

Also, on line 1 in variable main_code:
You have a long string that has the save and load game functionality. This string is vulnerable to code errors, as treats it like a string. Like how you made, create a file called and create functions for loading, saving, or deleting the save game.

edit: Hmmm..... It seems you were trying to create a multiline statement on line 31 in You must have forgotten to add 2 extra quotes to make it into a multiline. """This multiline statement is important for adding the extra line"""

There we go, the program is working!

The Conclusion

Now that everything is working again, we need to conclude what happened so we don't make that mistake again.

First, we need to use """ instead of ". """ creates a multiline string which can output in multiple lines. We could also use \n too.

multi = """
Hello World!
I am a multiline string!
What about you?
""" #multiline

print('Look Up,\nLook Down') #give a multiline


Look Up,
Look Down

Second, we shouldn't put all our code in a multiline string, as Repl can't detect code errors.

Third, we need to organize code into functions and classes which will help us understand the code. It's also nice to document it with #comments and """multilines""".

def load(): #loads savegame
    This load function loads savegame.
    Very Important Piece of the Game.

    Some errors on line 10
    print('Loaded!') #show msg when complete
    q = 1/0 #hmmm..... this seems to return an error.

Did it help? Mark this as the correct answer

launcherman08 (21)

@HarperframeInc Thank you! This was a really big help!

HarperframeInc (454)

@launcherman08 You already have a define statement in your multiline strings. You could put this into use by making a and file. Replit will be able to detect errors.