mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
Add flake8-builtins to pre-commit and fix errors (#7105)
Ignore `A003` Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
This commit is contained in:
@ -20,21 +20,21 @@ def odd_even_sort(input_list: list) -> list:
|
||||
>>> odd_even_sort([1 ,2 ,3 ,4])
|
||||
[1, 2, 3, 4]
|
||||
"""
|
||||
sorted = False
|
||||
while sorted is False: # Until all the indices are traversed keep looping
|
||||
sorted = True
|
||||
is_sorted = False
|
||||
while is_sorted is False: # Until all the indices are traversed keep looping
|
||||
is_sorted = True
|
||||
for i in range(0, len(input_list) - 1, 2): # iterating over all even indices
|
||||
if input_list[i] > input_list[i + 1]:
|
||||
|
||||
input_list[i], input_list[i + 1] = input_list[i + 1], input_list[i]
|
||||
# swapping if elements not in order
|
||||
sorted = False
|
||||
is_sorted = False
|
||||
|
||||
for i in range(1, len(input_list) - 1, 2): # iterating over all odd indices
|
||||
if input_list[i] > input_list[i + 1]:
|
||||
input_list[i], input_list[i + 1] = input_list[i + 1], input_list[i]
|
||||
# swapping if elements not in order
|
||||
sorted = False
|
||||
is_sorted = False
|
||||
return input_list
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user