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

后端 未结 9 1587
礼貌的吻别
礼貌的吻别 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:03

    The easiest way to read multiple lines from a prompt/console when you know exact number of lines you want your python to read, is list comprehension.

    lists = [ input() for i in range(2)]

    The code above reads 2 lines. And save inputs in a list.

提交回复
热议问题