From 7713c56c6150b94baf91e17311324b10783b7d7c Mon Sep 17 00:00:00 2001
From: "Bradley M. Small" <bradley_small@hotmail.com>
Date: Thu, 31 Oct 2019 20:46:01 -0400
Subject: [PATCH] making lint corrections

---
 bubblesort.py | 42 ++++++++++++++++++++----------------------
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/bubblesort.py b/bubblesort.py
index dd2c9ed..f8e4a5a 100755
--- a/bubblesort.py
+++ b/bubblesort.py
@@ -1,7 +1,5 @@
 #!/usr/bin/python3
-"""
-Program to demonstrate the bubble sort in python
-"""
+"""Program to demonstrate the bubble sort in python."""
 import random
 
 
@@ -9,9 +7,12 @@ MAX = 10
 
 
 def main():
-    """
-    main driver. creates the random list, then prints it, then calls
-    the sort function, outputs the sorted list.
+    """Demonstrate a bubble sort.
+
+    * Create the random list.
+    * Print.
+    * Sort.
+    * Output.
     """
     # This is an already sorted list
     # random_list = range(MAX)
@@ -29,33 +30,30 @@ def main():
 
 
 def swap(the_list, src_idx, dst_idx):
-    """
-    using the indexes swaps two values in a list
-    """
-    tmp = the_list[dst_idx]
-    the_list[dst_idx] = the_list[src_idx]
-    the_list[src_idx] = tmp
+    """Swap two values in a list."""
+    the_list[dst_idx], the_list[src_idx] = the_list[src_idx], the_list[dst_idx]
 
 
 def list_bubblesort(the_list):
-    """
-    classic bubble sort
-    tracking how many passes
+    """Sort a list.
+
+    Trackhow many passes.
+
+    Start from the first item in the list.
+    Walk the list until it can be swapped with a lower value or switch
+    to the larger value and continue down the list.
 
-    starting from the first item in the list
-    walk the list until it can be swapped with a lower value or switch
-    to the larger value and continue down the list
+    Loop back to the first item in the list.
 
-    loop back to the first item in the list
+    When list is passed with no swaps, it is sorted.
 
-    when list is passed with no swaps, it is sorted.
-    returns the number of passes.
+    Return the number of passes.
     """
     pass_no = 0
     done = False
     while not done:
         swapped = False
-        for next_one in range(1, len(the_list)):
+        for next_one, _ in enumerate(the_list[1:]):
             current = next_one - 1
             value = the_list[current]
             if value > the_list[next_one]:
-- 
GitLab