Skip to content

Last Item

Andrew Burke edited this page Apr 3, 2024 · 8 revisions

Could also do with looping and a temp variable instead of using len.

def get_last(lst):

if lst:

length = len(lst)

return lst[length-1]

else:

return None

Clone this wiki locally