Learn Data Structures by Building the Merge Sort Algorithm - Step 12

Tell us what’s happening:

The instructions have a mistake. They say, “Within the while loop, replace pass with an if statement that checks if the index of left_part is less than the index of right_part.” However, what the if statement actually has to check is whether the ELEMENT AT THE index of left_part is less than the ELEMENT AT THE index of right_part. (What I have is exactly what the feedback tells you to put.)

Your code so far

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


# User Editable Region

    while left_array_index < len(left_part) and right_array_index < len(right_part):
        if left_part[left_array_index] < right_part[right_array_index]:
            

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0

Challenge Information:

Learn Data Structures by Building the Merge Sort Algorithm - Step 12

Hi there! :waving_hand:

Your code is missing something inside the if statement. Try adding pass inside the if block

This ensures your code runs without errors while you continue working on it. Let me know if you need more help!

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.