How do I reverse a sublist in a list in place?

前端 未结 12 2680
-上瘾入骨i
-上瘾入骨i 2021-02-20 01:24

I\'m supposed to create a function, which input is a list and two numbers, the function reverses the sublist which its place is indicated by the two numbers. for example this is

12条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-20 02:23

    ... I'm not sure is it's in place.

    ...

    lst[start:end]=sublist
    

    Yes, it's in place. lst is never rebound, only its object mutated.

提交回复
热议问题