- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListInsert.py
More file actions
Latest commit
15 lines (15 loc) · 406 Bytes
/
Copy pathListInsert.py
File metadata and controls
15 lines (15 loc) · 406 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
n=int(input("Enter the number of items in the list:"))
print("Enter the elements:")
a= []
foriinrange(0, n):
k=int(input())
a.append(k)
a.append(0)
element=int(input("Enter the element to be inserted:"))
index=int(input("Enter the index value:"))
foriinrange(n, index, -1):
a[i] =a[i-1]
a[index] =element
print("List elements are:")
foriinrange(0, n+1):
print(a[i])