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:
The output:
[['1', '2'], ['1', '2'], ['1', '2'], ['1', '2']]
And take a look at what happens with this code in PyCharm:
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:
- Uninstalled PyCharm and Python.
- Removed all folders related to them (in AppData and so on).
- Downloaded and installed the latest versions of PyCharm and Python.
- Rebooted my laptop.
- Created a completely new project.
But it didn't help.
P.P.S. The option "Emulate terminal in output console" is not enabled:
CodePudding user response:
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
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