From ace984ecca366f73a4f82461b1592c8247720a08 Mon Sep 17 00:00:00 2001 From: UtkarshPrakash <48208181+UtkarshPrakash@users.noreply.github.com> Date: Sat, 26 Oct 2019 12:42:49 +0530 Subject: [PATCH] Update 16123004.py --- Bubble Sort/16123004.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Bubble Sort/16123004.py b/Bubble Sort/16123004.py index c2eabcf..d393416 100644 --- a/Bubble Sort/16123004.py +++ b/Bubble Sort/16123004.py @@ -1,7 +1,15 @@ -l = [ 2,3,4,5,6,8] +l = [2,3,4,5,6,8] +number = int(input("Please Enter the Total Number of Elements : ")) +for i in range(number): + value = int(input("Please enter the %d Element of List1 : " %i)) + l.append(value) -n = len(l) -for i in n: - # TODO Fill Code here +for i in range(number -1): + for j in range(number - i - 1): + if(l[j] > l[j + 1]): + temp = l[j] + l[j] = l[j + 1] + l[j + 1] = temp +print("The Sorted List in Ascending Order : ", l)