How can the user enter a new line in the input? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

12th Jun 2017, 5:28 PM
Insiya Tankiwala
2 Answers
+ 6
1) use \n 2) use an interactive console meaning a console which allows you to enter new lines also
12th Jun 2017, 6:01 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 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)
12th Jun 2017, 7:05 PM
visph
visph - avatar