0

The input:

359716482
867345912
413928675
398574126
546281739
172639548
984163257
621857394
735492861

If I directly paste the input into the IPython console it will look like this:

359716482
   ...: 867345912
   ...: 413928675
   ...: 398574126
   ...: 546281739
   ...: 172639548
   ...: 984163257
   ...: 621857394
   ...: 735492861

and a single input() will read everything into a single string, which then needs to be broken up manually. I'd like to make the input behave as if I entered every line separately and pressed Enter after entering every line, so a input() only reads a single number.

  • Here is answer, https://stackoverflow.com/questions/30239092/how-to-get-multiline-input-from-user – Santosh Shinde Oct 26 '21 at 13:51
  • @SantoshShinde This is not what I asked. I want a way to break up the multiple line input before it is passed to python. – asdfasdascvd Oct 26 '21 at 13:55
  • Are you copying this data from excel and the pasting is including "returns" between each number? – stan61285 Oct 26 '21 at 13:58
  • @stan61285 No, copying this data from anywhere will cause this problem. – asdfasdascvd Oct 26 '21 at 14:01
  • The hard part is that is will be highly implementation dependant. I tested it on command line python, and input reads only the first line, and the interpretor tries to process the following lines. On IDLE input only read the first line, and the following lines are buffered for other input or read commands, while the interpretor ignores them. So my answer would be: do not use IPython here, but the good old IDLE... – Serge Ballesta Oct 26 '21 at 14:09
  • @Serge Ballesta This works, thank you! But I wonder if there is a way to do it on IPython, as it has many features that IDLE lacks. – asdfasdascvd Oct 26 '21 at 14:13
  • @asdfasdascvd: I do not use IPython. That is the reason why I only posted a comment, because I am aware that it is not the expected answer :-) Just hoped it could help you (or others) as a hint... – Serge Ballesta Oct 26 '21 at 14:18

0 Answers0