+ 1
How can the user enter a new line in the input?
For example if he wants to type the text in this format: abc xyz
2 ответов
+ 6
1) use \n
2) use an interactive console meaning a console which allows you to enter new lines also
+ 2
import sys
print('Enter some text on multi-line using return key, end your entry with typing \'quit\' alone on a new line...')
buff = []
while True:
line = sys.stdin.readline().rstrip('\n')
if line == 'quit':
break
else:
buff.append(line)
print('---')
print(buff)