Store multi-line input into a String (Python)

前端 未结 5 1835
鱼传尺愫
鱼传尺愫 2021-02-06 16:28

Input:

359716482
867345912
413928675
398574126
546281739
172639548
984163257
621857394
735492861

my co

5条回答
  •  旧巷少年郎
    2021-02-06 16:55

    Each input() will only accept a single line. Strategies around this:

    • You can repeatedly call input() in a loop until it receives a blank line
    • You can repeatedly call input() in a loop until the user does ctrl-D on a UNIX-like OS, at which point EOFError will be raised which you can catch
    • Read the data from a text file or other more appropriate source than stdin

提交回复
热议问题