From c9c4fb156f7523f60afd1f52921991ca732becd0 Mon Sep 17 00:00:00 2001 From: Aadil Idreesi <67253557+AadilRazw@users.noreply.github.com> Date: Wed, 5 Oct 2022 08:27:50 +0530 Subject: [PATCH] Added bubblesort.py --- BubbleSort.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 BubbleSort.py diff --git a/BubbleSort.py b/BubbleSort.py new file mode 100644 index 0000000..d932ea0 --- /dev/null +++ b/BubbleSort.py @@ -0,0 +1,16 @@ +A = [] +n = int(input("Enter number of elements: ")) + +for i in range(n): + elm = int(input("Enter the element: ")) + A.append(elm) +l = len(A) +i = 0 +print(f"Old list Was {A}") +while i!=l: + N = l-i-1 + for j in range(N): + if A[j]>=A[j+1]: + A[j],A[j+1]=A[j+1],A[j] + i+=1 +print(f"New list is {A}")