0

Can anyone help me ?

Input Format The first line contains an integer, N (the size of our array). The second line contains N space-separated integers describing array 's A elements. How to I get a space seperated input from user?

26th Apr 2020, 8:09 AM
Ramya Thiurmalisamy
Ramya Thiurmalisamy - avatar
5 Answers
+ 2
Ramya Thiurmalisamy For example array size =5 And then if you input "1 2 3 4 5" as a string ,split will turn them into list with seperated numbers ,
26th Apr 2020, 8:16 AM
Abhay
Abhay - avatar
+ 2
store the user input in variable 'inp' split user input at spaces print the resulting list
26th Apr 2020, 8:17 AM
visph
visph - avatar
+ 2
be aware that split produce a list of string, even if there are only digits... you need to cast them to int ^^
26th Apr 2020, 8:18 AM
visph
visph - avatar
+ 1
inp = input(">>> ") inp = inp.split(" ") print(inp)
26th Apr 2020, 8:11 AM
visph
visph - avatar
0
visph can you please explain it?
26th Apr 2020, 8:12 AM
Ramya Thiurmalisamy
Ramya Thiurmalisamy - avatar