how to input multiple lines with space to a list by python

I want to ask the user to add n lines with space like:

2 5 
3 13 

and save them in a list like [2, 5, 3, 13].

I traied : x= list(map(int, input() .split())) didnt work

also traid: x=[ int(x) for x in sys.stdin.read().split() ] , but the problem is that I cant stop it automatically.



Read more here: https://stackoverflow.com/questions/68475622/how-to-input-multiple-lines-with-space-to-a-list-by-python

Content Attribution

This content was originally published by Menem Ali at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: