---
id: 656702f8b4cbd8cbf0a433c6
title: Step 11
challengeType: 20
dashedName: step-11
---

# --description--

Inside your function, create a `while` loop that compares an element in `left_part` to an element in `right_part`, and merges the smaller element to the main `array` list. 

Create two conditions for the loop: one that checks whether the `left_array_index` is less than the length of `left_part` and another condition that checks whether `right_array_index` is less than the length of `right_part`.

# --hints--

Your `while` loop should have these conditions: `left_array_index < len(left_part) and right_array_index < len(right_part)`. Don't forget to use the `pass` keyword in the body of the loop.

```js
({
  test: () => {
    const transformedCode = code.replace(/\r/g, "");
    const merge_sort = __helpers.python.getDef("\n" + transformedCode, "merge_sort");
    const { function_body } = merge_sort;

    assert.match(function_body, /while\s+left_array_index\s*<\s*len\(\s*left_part\s*\)\s+and\s+right_array_index\s*<\s*len\(\s*right_part\s*\):/);
  }
})
```

Use the `pass` keyword in the body of the loop

```js
({
  test: () => {
    const transformedCode = code.replace(/\r/g, "");
    const merge_sort = __helpers.python.getDef("\n" + transformedCode, "merge_sort");
    const { function_body } = merge_sort;

    assert.match(function_body, /while\s+left_array_index\s*<\s*len\(\s*left_part\s*\)\s+and\s+right_array_index\s*<\s*len\(\s*right_part\s*\):\s*pass/);
  }
})
```

# --seed--

## --seed-contents--

```py
def merge_sort(array):
    
    middle_point = len(array) // 2
    left_part = array[:middle_point]
    right_part = array[middle_point:]

    merge_sort(left_part)
    merge_sort(right_part)

    left_array_index = 0
    right_array_index = 0
    sorted_index = 0

--fcc-editable-region--

--fcc-editable-region--
```
