How to allow list append() method to return the new list

前端 未结 7 1618
春和景丽
春和景丽 2020-12-09 00:31

I want to do something like this:

myList = [10,20,30]
yourList = myList.append (40)

Unfortunately, list append does not return the modified

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-09 00:55

    You only need to do myList.append(40)

    It will append it to the original list, not return a new list.

提交回复
热议问题