+ 4

Receive n number in one line

How can I write a program in Python that: I receive a number (n) from the user in the first line and in the next line I receive n number in one line and save it in the list? Like this: 5 1 2 3 4 5

19th Apr 2020, 7:03 AM
SUN
SUN - avatar
3 Réponses
+ 5
You can use map and convert it to the list. For eg. L=list(map(int,input().split())) This will create a list L of integers.
19th Apr 2020, 8:06 AM
Pooja Somani
Pooja Somani - avatar
+ 6
Thanks Pooja Somani
19th Apr 2020, 9:27 AM
SUN
SUN - avatar
+ 1
Did you try self?
19th Apr 2020, 7:11 AM
A͢J
A͢J - avatar