From ea57eedadba4546a6c803ca833686b1b2df34481 Mon Sep 17 00:00:00 2001 From: Frank Delaguila Date: Wed, 12 Mar 2025 23:32:46 -0600 Subject: [PATCH] Adding in folder for python --- python/bubble-sort.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 python/bubble-sort.py diff --git a/python/bubble-sort.py b/python/bubble-sort.py new file mode 100644 index 0000000..e57a63d --- /dev/null +++ b/python/bubble-sort.py @@ -0,0 +1,15 @@ +def bubble_sort(nums): + swapping = True + end = len(nums) + while swapping: + swapping = False + for i in range(1, end): + if nums[i - 1] > nums[i]: + temp = nums[i - 1] + nums[i - 1] = nums[i] + nums[i] = temp + swapping = True + end -= 1 + return nums + +print(bubble_sort([5, 7, 3, 6, 8])) \ No newline at end of file