30秒学会 Python 片段 – last
Returns the last element in a list.
use lst[-1]
to return the last element of the passed list.
代码实现
def last(lst):
return lst[-1]
使用样例
last([1, 2, 3]) # 3
分享文章、钻研技术、改变生活!
Returns the last element in a list.
use lst[-1]
to return the last element of the passed list.
def last(lst):
return lst[-1]
last([1, 2, 3]) # 3