-1

When I try to run my code it returns with none.

def gnomeSort(lis):
    i = 0
    n = len(lis)
    while i < n:
        if i and lis[i] < lis[i-1]:
            lis[i], lis[i-1] = lis[i-1], lis[i]
            i -= 1
        else:
            i += 1
    return


lis = [1,3,5,20,19,30,2,6,19,23,31,90,44,62,69,21,78,89,64]
print(gnomeSort(lis))

When I run this it returns with "None", even though I provided a list to be sorted.

Prune
  • 76,765
  • 14
  • 60
  • 81
Noah Santos
  • 123
  • 1
  • 10

1 Answers1

3

Your wrote your function much like the built-in sort functions: it sorts the list in place and returns None. Print the sorted list, not the return value.

print(lis)
Prune
  • 76,765
  • 14
  • 60
  • 81