Jacky Xie Jacky Xie - 3 months ago 9
Python Question

How can I get user input with line breaks

When I do something like

userInput = input("Type in text")


and type in a piece of text like

"""
Line
Break
"""


that I copied from somewhere, the python console only assigns gets the first line, and then the next lines end up as the console thinking I'm trying to find a variable, with

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Break' is not defined


as an error message. How would I get all the user input?

Answer
print "ENTER STUFF:"
user_input="\n".join(iter(raw_input,""))

I guess ...

Comments