diff --git a/snippets/bubble_sort.md b/snippets/bubble_sort.md index 1f81b3324..281d5e554 100644 --- a/snippets/bubble_sort.md +++ b/snippets/bubble_sort.md @@ -6,9 +6,7 @@ def bubble_sort(lst): for passnum in range(len(lst) - 1, 0, -1): for i in range(passnum): if lst[i] > lst[i + 1]: - temp = lst[i] - lst[i] = lst[i + 1] - lst[i + 1] = temp + lst[i], lst[i + 1] = lst[i + 1], lst[i] ``` diff --git a/test/bubble_sort/bubble_sort.py b/test/bubble_sort/bubble_sort.py index c8000f193..48ce048e1 100644 --- a/test/bubble_sort/bubble_sort.py +++ b/test/bubble_sort/bubble_sort.py @@ -2,6 +2,4 @@ def bubble_sort(lst): for passnum in range(len(lst) - 1, 0, -1): for i in range(passnum): if lst[i] > lst[i + 1]: - temp = lst[i] - lst[i] = lst[i + 1] - lst[i + 1] = temp \ No newline at end of file + lst[i], lst[i + 1] = lst[i + 1], lst[i] diff --git a/test/bubble_sort/bubble_sort.test.py b/test/bubble_sort/bubble_sort.test.py index 08627cfef..139cf6e95 100644 --- a/test/bubble_sort/bubble_sort.test.py +++ b/test/bubble_sort/bubble_sort.test.py @@ -1,6 +1,15 @@ -import types,functools +import types +import functools from pytape import test from bubble_sort import bubble_sort + + def bubble_sort_test(t): -t.true(isinstance(bubble_sort, (types.BuiltinFunctionType, types.FunctionType, functools.partial)),'.snippet object at 0x7fc8ea4c6978> is a function') -test('Testing bubble_sort',bubble_sort_test) \ No newline at end of file + t.true( + isinstance(bubble_sort, (types.BuiltinFunctionType, types.FunctionType, + functools.partial)), + '.snippet object at 0x7fc8ea4c6978> is a function' + ) + + +test('Testing bubble_sort', bubble_sort_test)