How do I read multiple lines of raw input in Python?

后端 未结 9 1420
礼貌的吻别
礼貌的吻别 2020-11-22 09:28

I want to create a Python program which takes in multiple lines of user input. For example:

This is a multilined inp         


        
9条回答
  •  清酒与你
    2020-11-22 10:12

    Keep reading lines until the user enters an empty line (or change stopword to something else)

    text = ""
    stopword = ""
    while True:
        line = raw_input()
        if line.strip() == stopword:
            break
        text += "%s\n" % line
    print text
    

提交回复
热议问题