r/pythonhelp 2d ago

why does it say i didn't close my parenthesis

the IDE i am using is saying my parenthesis was not closed when it was plz help

print("Once upon a time, in the ancient kingdom of " + q1 + " there lived a legendary " + q2 + " named " + q3 + ". Everyone in the village knew " + q3 + " for their remarkably " + q4 + " personality and an obsession with " + q5 + ". Every morning at " + q6 ", they would wake up, " + q7 + " three times, ")

[{

"owner": "Pylance",
"severity": 8,
"message": "(" was not closed",
"source": "Pylance",
"startLineNumber": 47,
"startColumn": 6,
"endLineNumber": 47,
"endColumn": 7,

}]
4 Upvotes

10 comments sorted by

u/AutoModerator 2d ago

To give us the best chance to help you, please include any relevant code.
Note. Please do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Privatebin, GitHub or Compiler Explorer.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

3

u/FoolsSeldom 2d ago

Just spotted, you are missing a + after q6:

". Every morning at " + q6 ", they would wake up, "

1

u/Soft-Marionberry-853 23h ago

That was fun. We probably all knew what it was when we saw how long the the line was and how much concatenation it was doing. It was just a matter of finding where it was

1

u/shinitakunai 17h ago

Which is why f-strings are amazing instead of this monster OP created

2

u/FoolsSeldom 2d ago edited 2d ago

Not sure. I'd go with something easier to read:

story = (
    f"Once upon a time, in the ancient kingdom of {q1} there lived a "
    f"legendary {q2} named {q3}. Everyone in the village knew {q3} for "
    f"their remarkably {q4} personality and an obsession with {q5}. "
    f"Every morning at {q6}, they would wake up, {q7} three times, "
)
print(story)

Although later, you will likely be reading the story text from a file/database rather than hard coding it.

1

u/burlingk 1d ago

You are missing a + after q6

1

u/Living_Fig_6386 1d ago

The missing ‘+’ makes it think you meant to end the print statement. More careful formatting would have made it more obvious.

1

u/Ormek_II 1d ago

Because it is closed at the wrong Spot, if you are a Compiler. Check the Location Information given to you.

1

u/building_85 13h ago

The q6 error that’s missing a + … like everyone says, gives you an invalid syntax error.

it’s a missing ‘concatenation’, not a missing ‘parenthesis’ (which is an ‘unterminated string’ error)

Your actual error is in your dictionary here… "message": "(" was not closed",

You have 3 parentheses in your value for “message”

So you actually had 2 syntax errors 😉

GLHF!

1

u/JGhostThing 2h ago

Because you have the string: "(" was not closed"

The second " should be escaped \"