Getting the last element of a list

后端 未结 12 1269
一向
一向 2020-11-22 04:58

In Python, how do you get the last element of a list?

12条回答
  •  名媛妹妹
    2020-11-22 06:04

    You can also do:

    alist.pop()
    

    It depends on what you want to do with your list because the pop() method will delete the last element.

提交回复
热议问题