I am trying to take all the input at once for compititive programming. The best way I found was the sys.stdin(I am coding in python).
This method works fine when I submit the code to the online judge. But the problem is when I am trying to use it on my code edditor(PyCharm/VSCode). After I run the program, The input field is continuously taking input and I can not identify where to stop taking input.
I am sharing a simplified code to show the attempts I make.
import sys
data = sys.stdin.read()
print(data)
I run this code and it never stop taking input so I tried another approch which was taking input form file. I created a input.txt
file and enter the all input at once. Next, I run the program with command prompt
.
python sample_program.py < input.txt
The command was not working on powershell
because <
is reserved for powershell but it’s worked fine in command prompt
Now, I want to know is there any way to setup my code edditor or by changing code to direct run the program and input all at once without need of an external file?