I want to ask the user to add n lines with space like:
and save them in a list like [2, 5, 3, 13].
I traied :
x= list(map(int, input() .split())) didnt work
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
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.