a. Insert elements at given position of the list
b. Remove elements from given position of the list
c. Sort list in descending order
d. Append elements
e. Create list with in a particular range
l1=["CPPM","Maths","IC","CS"] #blank list
l2=[]
while(True):
print("====================================")
print("MENU DRIVEN PROGRAM ON LIST")
print("a.Insert elements at given position of the list")
print("b. Remove elements from given position of the list")
print("c. Sort list in descending order")
print("d. Append elements")
print("e. Create list with in a particular range")
print("f.exit")
ch=input("Enter any choice from following=>")
if ch=='f':
break
elif ch=='a':
pos=int(input("Enter position"))
ele=input("Enter element")
l1.insert(pos,ele)
print(l1)
elif ch=='b':
pos=int(input("Enter position"))
l1.pop(pos)
print(l1)
elif ch=='c':
l1.sort()
l1.reverse()
print(l1)
elif ch=='d':
ele=input("Enter element you want to append")
l1.append(ele)
print(l1)
elif ch=='e':
x=int(input("Starting number"))
y=int(input("Ending number"))
l2=[*range(x,y+1)]
print(l2)
Leave a Reply