0

Code running in PyCharm does not run as it should. Here it is:

crd = [input().split() for _i in range(int(input()))]

print(crd)

The input:

4
1 2
1 2
1 2
1 2

Take a look at the screenshot of the code running in the console:

enter image description here

The output:

[['1', '2'], ['1', '2'], ['1', '2'], ['1', '2']]

And take a look at what happens with this code in PyCharm:

enter image description here

The output (I can't even complete the input):

[[], ['1', '2'], [], ['1', '2']]

I have no idea what is going on here.

P.S. I have already done the following:

  1. Uninstalled PyCharm and Python.
  2. Removed all folders related to them (in AppData and so on).
  3. Downloaded and installed the latest versions of PyCharm and Python.
  4. Rebooted my laptop.
  5. Created a completely new project.

But it didn't help.

P.P.S. The option "Emulate terminal in output console" is not enabled:

enter image description here

fallincode
  • 379
  • 4
  • 14
  • Please enter code, input and output as text instead of screenshots. Some companies blocks the images, images are not searchable, image host mig remove image, we can't copy your code e.t.c. – Cleared May 20 '22 at 19:33
  • The question is fixed. – fallincode May 20 '22 at 19:35
  • This does not really answer your question but my best guess is that's its related to input() in combination with running in Pycharm which might give you something to Google. Looks like pycharm sends a black line extra after each input. This looks like similar issue: https://stackoverflow.com/questions/35829176/input-in-python-does-not-wait-for-my-input-in-pycharm – Cleared May 20 '22 at 19:41

1 Answers1

1

This is a bug. I just tried it and it does the same thing on my machine, however when I run it through the pycharm debugger it allowed me to enter all 4 inputs and output the correct result.

A temporary workaround is to enable the "Emulate terminal in output console" for a given in Modify Run Configurations which is available in the context menu if you left click on main.py enter image description here

here is a link to the issue tracker on the bug https://youtrack.jetbrains.com/issue/PY-54238/STDIN-is-lost-for-a-second-input-call

Alexander
  • 16,091
  • 5
  • 13
  • 29