# Here's the Python code, as promised! # Note that this Python is indented by two spaces, not the typical four, # in order to match with the video. def quicksort(array, low, high): if high
Hello, thanks for watching! It looks like your last two lines inside the partition function are over-indented. They will be inside the for loop, when they should be outside. Because these two lines are inside the for-loop, you return the partition before it is finished. You want to take two spaces off the left side of each line. Yeah, I see where it is off in the video, at the end of the section about partitioning. The code in the top comment and at the end of the video are correct, but there are extra spaces in the video for the partition function. I double-checked all that but it is rather hard to see that the alignment is off with only two spaces... Normally, Python uses 4-space indents, and it is easier to notice problems like this with 4-space indents. I use 2-space in the video so that the lines fit on screen a bit easier.
# Here's the Python code, as promised!
# Note that this Python is indented by two spaces, not the typical four,
# in order to match with the video.
def quicksort(array, low, high):
if high
I don't seem to get the correct result with the following code:
def quickSort(array, low, high):
if high
Hello, thanks for watching!
It looks like your last two lines inside the partition function are over-indented. They will be inside the for loop, when they should be outside. Because these two lines are inside the for-loop, you return the partition before it is finished. You want to take two spaces off the left side of each line.
Yeah, I see where it is off in the video, at the end of the section about partitioning. The code in the top comment and at the end of the video are correct, but there are extra spaces in the video for the partition function. I double-checked all that but it is rather hard to see that the alignment is off with only two spaces... Normally, Python uses 4-space indents, and it is easier to notice problems like this with 4-space indents. I use 2-space in the video so that the lines fit on screen a bit easier.