How to read multiple lines of raw input?

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

To get every line as a string you can do:

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

Python 2:

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

Leave a Comment