Reputation:
When I am trying to append data, it gives list index out of range error.
n = int(input('Enter Range'))
arr=[]
for i in range(0,n):
print(i)
arr[i].append(input('Enter Number'))
arr.sort()
print(arr)
Upvotes: 0
Views: 69
Reputation: 678
arr.append() function will append element to the end of the list
n = int(input('Enter Range'))
arr=[]
for i in range(0,n):
print(i)
arr.append(input('Enter Number')) # Modify this line
arr.sort()
print(arr)
Upvotes: 2