Bubble sorting in pytthon|Sorting techniques in python |Python Code for bubble sorting

Introduction

In this blog you will learn about a sorting technique(Bubblesorting).You will also get the code for bubble sorting.

Bubble Sorting

It is a  sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.

Source code-

list1= eval(input("Enter the list of numbers :  "))

n=len(list1)

for i in range(n):

for j in range(0,n-i-1):

if list1[j]> list1[j+1]:

list1[j],list1[j+1]=list1[j+1],list1[j]

print("sorted list is:",list1)

#CODE ENDED


Output:-




"Hope it helped"
Have anything in mind? Let me 
know in the comment section👇

Next Post Previous Post
No Comment
Add Comment
comment url