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.

3
  • I believe this to be related. stackoverflow.com/questions/11664443/… Commented Feb 26, 2015 at 18:49
  • it is pointless to call .splitlines() on the output of raw_input() that reads at most one line. Commented Feb 26, 2015 at 21:36
  • This not duplicate question at all. This is related to python 2 not python 3, as question says. Commented Feb 26, 2015 at 22:26

1 Answer 1

3

just try.

aux = ''
'\n'.join(iter(input, aux))
Sign up to request clarification or add additional context in comments.

1 Comment

@DSM oh yes, I forgot it, I changed it to input, thx.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.