-2
print(<expr>, <expr>, ..., <expr>, end="\n")

SyntaxError: invalid syntax

print("The answer is", end=" ")
print(3 + 4)

SyntaxError: multiple statements found while compiling a single statement

Expected output:

The answer is 7

print("The answer is", end=" ")

The answer is print(3 + 4)

7

not_speshal
  • 22,093
  • 2
  • 15
  • 30
  • 2
    What is your question? – Scott Hunter Aug 11 '23 at 15:50
  • 1
    The second set of `print` statements give the expected output. What is the issue? – not_speshal Aug 11 '23 at 15:50
  • Are you using Python 2? That's the only reason I can imagine for a `SyntaxError` in that code. – Blckknght Aug 11 '23 at 15:50
  • Does this answer your question? [SyntaxError: multiple statements found while compiling a single statement](https://stackoverflow.com/questions/21226808/syntaxerror-multiple-statements-found-while-compiling-a-single-statement) – slothrop Aug 11 '23 at 15:53
  • 2
    @Blckknght not always. If you are trying to copy paste multiple lines into a shell it can complain like this – C.Nivs Aug 11 '23 at 16:02

0 Answers0