Reputation: 97
When I run the code
print("Hi")
input("Hello: ")
on Python Tutor (Python 3.6), I get the expected output (ignoring my input)
Hi
Hello:
However, when I run the same two lines on my computer, using Spyder 3.3.1 and Python 3.7 I get the output
Hi
Hello:
I would like to understand why this blank line appears in Spyder, and also how to get rid of it.
Upvotes: 2
Views: 2577
Reputation: 1123420
This is a Spyder's bug and it was fixed in its 5.3.1 version, released on May 2022.
Note: Please be sure to also have version 5.3.1 of the Qtconsole package to avoid a bug that appeared while fixing this one.
Upvotes: 3
Reputation: 496
The OP's question has two parts:
Martijn Pieters' answer, where he points out that this is a known issue, only addresses the first part. This answer addresses the second.
Do the following to remove print
's default newline:
print("Hi", end="")
input("Hello: ")
Which will return:
Hi
Hello:
Take note: This is a bit of a hack, i.e. it does not remove the newline that precedes input
. As a result, if you run your script anywhere other than in Spyder the above code will return:
HiHello:
Since this is a minor quirk that is specific to Spyder, it likely makes more sense just to tolerate it and move on.
Upvotes: 0