Sunday, March 3, 2019

Insert into list at given position - Python3

a=[]
n=int(input("Enter the size of list:"))
for i in range(n) :
    x=int(input("Enter the value: "))
    a.append(x);
print(a)
z=int(input("Insert an element to append in list:"))

y=int(input("Enter the position for the entered element:"))
a.insert(y,z)
print("Appended list is:",a)

ScreenShot:



No comments:

Post a Comment