felix001 felix001 - 1 year ago 203
Python Question

Raw input across multiple lines in Python

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

Answer Source
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))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download