Write a function that takes a list that is sorted in ascending order and a number as argument. The function should do the following:
Write a function that takes a list that is sorted in ascending order and a number as argument. The function should do the following:
- Insert the number passed as argument in a sorted list.
- Delete the number from the list.
13 views
1 Answers
from bisect import bisect
def listfunc(sortedlist,number) :
insert_point = bisect (sortedlist, number)
sortedlist.insert(insert_point,number)
print “List after Insertion”
print sortedlist
sortedlist.remove(number)
print “List after Deletion”
print sortedlist
maxrange = inputfEnter Count of numbers: ”)
numlist=[]
flag=False
for i in range(0, maxrange):
numlist.append(input(“ ?”))
numlist.sort()
number = inputfEnter the number”)
listfunc(numlist,number)
13 views
Answered