Python Sort() method

后端 未结 4 487
感情败类
感情败类 2020-12-11 09:22

I am starting to learn Python.

Can someone explain why sort() returns None?

alist.sort()            ## correct
alist = blist.sort()    ## NO incorrec         


        
4条回答
  •  被撕碎了的回忆
    2020-12-11 09:49

    When you want to perform the sorting on same list then you have to use sort() method of list. But If you dont want to change the sequence of original list but you need a sorted copy of the original list then use sorted() inbuilt function.

提交回复
热议问题