Aug-22-2018, 04:32 AM
Hello to the forum. As you can tell from the title, I am just learning python, and its use as a jupyter notbook.
I have this cell with a few lines of code that seems to run fine, under pycharm, when I use it in a file type of pure python. But when I use that same code in a file type ipynb, I get an "invalid syntax" error.
Here is the error:
print quicksort([3, 6, 8, 10, 1, 2, 1])
syntax error
Thank You
Tom
I have this cell with a few lines of code that seems to run fine, under pycharm, when I use it in a file type of pure python. But when I use that same code in a file type ipynb, I get an "invalid syntax" error.
def quicksort(arr): if len(arr) <= 1: return arr pivot = arr[len(arr) // 2] left = [x for x in arr if x < pivot] middle = [x for x in arr if x == pivot] right = [x for x in arr if x > pivot] return quicksort(left) + middle + quicksort(right) print quicksort([3, 6, 8, 10, 1, 2, 1])
Here is the error:
print quicksort([3, 6, 8, 10, 1, 2, 1])
syntax error
Thank You
Tom