Q. Write a function to insert an element in a sorted list only if it already exists in the list.

(i.e., only duplicate entries can be inserted.


Answer = 




def ins(num):
    if num in lst :
        lst.append(num)

lst = eval(input("Enter a sorted list :-"))
num = int(input("Enter a number :- "))
ins(num)
print("New list :-", lst)



Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post