1

I am trying to create a simple programme that inputs a single multiline input and outputs it as a table.

input:

a
b
c

I know i could have done this is easily in python 2.7.5 by using:

input_string = raw_input("> ").splitlines()

this would return ['a', 'b', 'c']

however in python 3, the line:

input_string = input("> ").splitlines()

only returns ['a'] hence it only reads the first line of the input string.

Is there any way in python 3 to accept a multiline input? Thanks.

levi
  • 22,001
  • 7
  • 73
  • 74
  • I believe this to be related. http://stackoverflow.com/questions/11664443/raw-input-across-multiple-lines-in-python – Kelvin Feb 26 '15 at 18:49
  • it is pointless to call `.splitlines()` on the output of `raw_input()` that reads at most one line. – jfs Feb 26 '15 at 21:36
  • This not duplicate question at all. This is related to python 2 not python 3, as question says. – levi Feb 26 '15 at 22:26

1 Answers1

3

just try.

aux = ''
'\n'.join(iter(input, aux))
levi
  • 22,001
  • 7
  • 73
  • 74