sort() and reverse() functions do not work

后端 未结 4 634
轻奢々
轻奢々 2020-11-22 12:42

I was trying to test how the lists in python works according to a tutorial I was reading. When I tried to use list.sort() or list.reverse(), the in

4条回答
  •  再見小時候
    2020-11-22 12:52

    For reference, you can see the documentation here specifically says:

    The sort() and reverse() methods modify the list in place for economy of space when sorting or reversing a large list. To remind you that they operate by side effect, they don’t return the sorted or reversed list.

    Don't be afraid to read the manual!

提交回复
热议问题