raw_input on several lines
larry.bates at websafe.com`
Sat Aug 2 22:22:53 CEST 2008
> Hi everybody,
> When using raw_input(), the input of the user ends when he types Return on
> his keyboard.
> How can I change this behavior, so that another action is needed to stop the
> input? For example, CTRL-G. It would allow the user to input several lines.
Just put raw_input() in a loop and check for something. Actually a blank line
would probably work best in that case. Not tested, but you will get the idea:
lines = list()
print 'Enter your text (empty line to quit)'
line = raw_input('')
if line.strip() == '':
More information about the Python-list