-1
# Bubble Sort
def sort(arr):
    while True:
        corrected = False
        for i in range(0, len(arr) - 1):
            if arr[i] > arr[i+1]:
                arr[i], arr[i+1] = arr[i+1], arr[i]
                corrected = True
        if not corrected:
                return arr

print sort([1, 2, 3, 4, 5, 6])
print sort([4, 3, 2, 1, 0, 99])
print sort([6, 5, 4, 3, 2, 1])

I am getting the following error: Please help.

/Users/tanujraitaneja/PycharmProjects/Giraffe/venv/bin/python /Users/tanujraitaneja/Library/Preferences/PyCharmCE2018.2/scratches/scratch.py
  File "/Users/tanujraitaneja/Library/Preferences/PyCharmCE2018.2/scratches/scratch.py", line 11
    print sort([1, 2, 3, 4, 5, 6])
         ^
**SyntaxError: invalid syntax**

**Process finished with exit code 1**
Tanuj
  • 3
  • 3
  • which version of python are you using? if you are using python 3.* you should use print with parentheses : print(sort([6, 5, 4, 3, 2, 1])) – Arya11 Aug 19 '18 at 08:45
  • Are you using Python 3? Then it's `print(sort([1, 2, 3, 4, 5, 6]))`, with parentheses for the print function. – 9769953 Aug 19 '18 at 08:45

1 Answers1

0

You're using python 3? Then you need to wrap your function call inside ()

print(sort([1, 2, 3, 4, 5, 6]))
print(sort([4, 3, 2, 1, 0, 99]))
print(sort([6, 5, 4, 3, 2, 1]))
Arielle Nguyen
  • 2,932
  • 1
  • 20
  • 15