Back

How to take input for array in single line

Created 4 years ago
397 Views
2 Comments
pavan2
@pavan2
pavan2
@pavan2Profile is locked. Login

I am really confused about how to get the input for an array or list in a single line i usually code in python and i use this logic

N=int(input())

a=list[]

for i in range(N):

x=int(input())

lst=a.append(x)

lst1=str(lst).replace(',' ,' ')

print(lst1)

This is how i code but while passing the input when i give the input as 1 2 3 4 5

I am getting an error . kindly help me how to wrtie a code for taking input for such kind.

ValueError: invalid literal for int() with base 10: '3 4 9 1 6'

Comments (2)
Please login to comment.