Sort a list of elements using bubble sort algorithm

Asked: Anonymously |Category: Python


a=[8,4,1,3,2,6]

for i in range(len(a)):

for j in range(1,len(a)):

if a[j-1]>a[j]:

a[j-1],a[j]=a[j],a[j-1]

print(a)

7 views0 comments

Recent Posts

See All

Binary string reduction in Python

Asked: Sudeep |Category: Python x=int(input("Enter the value of x : ")) for i in range(x): n=int(input("Enter the value of n : ")) y=input("Enter the value of y : ") l=list(y) k=0

"Believe you can and you're halfway there"