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

How do I fix a syntax error when it looks like there isn't one

I’m working on a small project and I’ve run into a SyntaxError. As far as I know, the syntax is correct but I’m not sure.

Here’s the code I used:

print(yellow + "You " green + "won" + yellow + " a total of " + cyan + str(correct_guess) + yellow + " game(s), and " + red + "lost" + yellow + " total of " + cyan + str(incorrect_guess) + yellow + " game(s).")

All of the variables used are defined in the code preceding this line (the variables named after colors being ANSI escape sequences that all work in other print lines). Here’s another line of code that doesn’t throw an error, but has the exact same syntax:

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

print(yelow + "Throughout all of the games played, you guessed a total of " + cyan + str(total_guess) + yellow + " times.")

This one works for some reason, while the one above does not.

When I ran the code it threw a SyntaxError. The code looks like it doesn’t have one, though. I’m not sure how to fix it. The code above defines all of the variables used, and I used proper indentation. It’s also telling me that the error comes after the final parenthesis.

>Solution :

Between "You " and green a + is missing.

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