From d357be4e528c9da3d6e89cb9f29ee5aac918b652 Mon Sep 17 00:00:00 2001 From: marina <138340846+bt3gl-cryptographer@users.noreply.github.com> Date: Wed, 2 Aug 2023 23:39:04 -0700 Subject: [PATCH] Update bubble_sort.py --- sorting/bubble_sort.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sorting/bubble_sort.py b/sorting/bubble_sort.py index 4a27baf..c4dd7bf 100644 --- a/sorting/bubble_sort.py +++ b/sorting/bubble_sort.py @@ -1,16 +1,15 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# author: bt3gl -def bubble_sort(list) +def bubble_sort(array) has_swapped = True while has_swapped: has_swapped = False - for i in range(len(lst) - 1): - if lst[i] > lst[i + 1]: - lst[i], lst[i + 1] = lst[i + 1], lst[i] + for i in range(len(array) - 1): + if array[i] > array[i + 1]: + array[i], array[i + 1] = array[i + 1], array[i] has_swapped = True