📌  相关文章
📜  python 列表的最后一个元素 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:19.133000             🧑  作者: Mango

代码示例6
import operator
# Python code to access the last element
# in a list using itemgetter() method
  
# Declaring and  initializing list 
number_list = [2, 1, 7, 4, 5, 3,6]
  
print ("List of elements are : " + str(number_list))

getLastElement = operator.itemgetter(-1)


# using [] operator to print last element
print("The last element of list using reverse method are : "
                            +  str(getLastElement(number_list)))