-1

how can I get this input from user and store it in a list in python?

3 4
5 7 3 7 9
2 1 20 3 2
8 1 20 1 1

when I use this code x = input() it just receives the 3 and 4.

but i want the output as list below: [3,4,5, 7, 3, 7, 9, 2, 1, 20, 3, 2, 8, 1, 20, 1, 1]

Robo
  • 19
  • 5
  • There are hundreds of posts and resources that tell you how to take input... why ask? Do you research... https://stackoverflow.com/questions/11664443/how-do-i-read-multiple-lines-of-raw-input-in-python & https://stackoverflow.com/questions/49064817/how-to-split-integer-input-in-python – Patrick Artner Jun 08 '21 at 15:02
  • then split each line and convert to int - also plenty of ressources for that:https://stackoverflow.com/questions/20449427/how-can-i-read-inputs-as-numbers – Patrick Artner Jun 08 '21 at 15:03
  • i've searched , i can do it with this code but there is a problem, user must hit the ENTER twice to make the code run : `from pip._vendor.distlib.compat import raw_input content = [] while True: line = raw_input() if line: content.append(line) else: break print(content)` – Robo Jun 08 '21 at 15:47
  • 1
    Does this answer your question? [How do I read multiple lines of raw input in Python?](https://stackoverflow.com/questions/11664443/how-do-i-read-multiple-lines-of-raw-input-in-python) – billoverton Jun 08 '21 at 18:14

1 Answers1

-1

You can use x = list(map(int, input().split()))