I’m struggling with the step 10. It asks to add three variables to the function and set them to 0. That’s what I did. But it seems that it’s not OK. I checked the indentation, I checked the spelling, … I don’t know what I did wrong.
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)
# User Editable Region
left_array_index=0
right_array_index=0
sorted_index=0
# User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0
Challenge Information:
Learn Data Structures by Building the Merge Sort Algorithm - Step 10
Always surround these binary operators with a single space on either side: assignment (=), augmented assignment (+=, -= etc.), comparisons (==, <, >, !=, <>, <=, >=, in, not in, is, is not), Booleans (and, or, not).
If operators with different priorities are used, consider adding whitespace around the operators with the lowest priority(ies). Use your own judgment; however, never use more than one space, and always have the same amount of whitespace on both sides of a binary operator:
# Correct:
i = i + 1
submitted += 1
x = x*2 - 1
hypot2 = x*x + y*y
c = (a+b) * (a-b)
# Wrong:
i=i+1
submitted +=1
x = x * 2 - 1
hypot2 = x * x + y * y
c = (a + b) * (a - b)
Although it would still run, I think it’s great if someone can learn the correct style. Ideally there could be different errors or hints for style violations that are otherwise syntax-correct but that would involve a lot of work…
without a consistent approach on making this style mandatory, there can’t be a sudden challenge that does have it mandatory. The AST helpers that we use primarily doesn’t have this mandatory, this test uses a regex test
Yeah, I meant to implement this for all of the Python curriculum would be a lot of work. Not super important I suppose, the style is implied in the code examples.