Q. Modify the function deleting an element from a sorted list so that only duplicate entries can be removed. An element which is unique in the list cannot be deleted.

e.g., from the array given below only 10, 35, 43 can be deleted as these have multiple entries; other elements cannot be deleted from it


[5, 10, 10, 12, 20, 35, 35, 35, 40, 42, 43, 43, 59, 70]


Answer =




def dele(lst):
    for i in lst :
        if lst.count( i ) > 1 :
            lst.remove( i )
    lst.sort( )

lst = eval(input("Enter a sorted list :-"))
dele(lst)
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