-2
def srt(number):
  list=[]
  list=sorted(number)
  return list


print srt([5,2,4,1,3])

It gives an error:

invalid syntax: print srt([5,2,4,1,3])

ᴀʀᴍᴀɴ
  • 4,443
  • 8
  • 37
  • 57
Deepak Jain
  • 137
  • 1
  • 3
  • 27
  • 1
    I think the error is clear so I add some remarks concerning the other code. You don't need `list=[]` because you overwrite `list` in the next line anyway. And you shouldn't call a variable `list` because you overwrite the built-in [`list`](https://docs.python.org/3/library/functions.html#func-list). The whole function body could be reduced to `return sorted(number)`. – Matthias Nov 26 '19 at 11:11
  • @Matthias or even just `srt = sorted` – Chris_Rands Nov 26 '19 at 11:12

1 Answers1

4
def srt(number):
    my_list=[]
    my_list=sorted(number)
    return my_list

print (srt([5,2,4,1,3]))

you forgot the () for print

Chrisvdberge
  • 1,824
  • 6
  • 24
  • 46