for i in range(left, right): if values[i] > values[i + 1]: values[i], values[i + 1] = values[i + 1], values[i]
Hi! I am doing this function but it isn't working. how can I fix it
def bubble_down(values: list, left: int, right: int) -> None:
"""Bubble down through values[left: right+1], swapping items that are out
of order. Note that use of this slicing notation means that items
values[left], values[left + 1], values[left + 2], ..., values[right] could
be modified.
Precondition: left and right are valid indexes in values.
>>> list_example_1 = [4, 3, 2, 1, 0]
>>> bubble_down(list_example_1, 1, 3)
>>> list_example_1
[4, 1, 3, 2, 0]
>>> list_example_2 = [4, 3, 2, 1, 0]
>>> bubble_down(list_example_2, 0, 4)
>>> list_example_2
[0, 4, 3, 2, 1]
"""
for i in range(left, right):
if values[i] > values[i + 1]:
values[i], values[i + 1] = values[i + 1], values[i]
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)