python array | Write a program to delete an element from sorted array so that new array is also sorted one. Email ThisBlogThis!Share to TwitterShare to Facebook Reactions: Python 2 Comments
This comment has been removed by the author.
ReplyDeletedef sor(a,t):
ReplyDeleteprint a
for i in range(1,t):
for j in range(0,t-i):
if a[j]>a[j+1]:
temp=a[j]
a[j]=a[j+1]
a[j+1]=temp
print a
mylist=[43,5,4,23,4,45,5,655]
s=len(mylist)
sor(mylist,s)
new=int(raw_input("enter the number"))
del mylist[new]
p=len(mylist)
sor(mylist,p)
[43, 5, 4, 23, 4, 45, 5, 655]
[4, 4, 5, 5, 23, 43, 45, 655]
enter the number4
[4, 4, 5, 5, 43, 45, 655]
[4, 4, 5, 5, 43, 45, 655]