felix001 felix001 - 2 months ago 22
Python Question

Raw input across multiple lines in Python

Does anyone know how to create a raw input that will take multiple lines ?

Answer
sentinel = '' # ends when this string is seen
for line in iter(raw_input, sentinel):
    pass # do things here

To get every line as a string you can do:

'\n'.join(iter(raw_input, sentinel))

Python 3:

'\n'.join(iter(input, sentinel))