Addressing the last element of a list

pinkfloydhomer at pinkfloydhomer at
Tue Nov 8 10:04:13 CET 2005

Or alternatively:

Is there a way to make reference to the last element of a list, to use
as a shorthand:

ref := &lst[len(lst) - 1] # I know syntax is wrong, but you get the

and then using the last element of the list by (assuming the element is
a dict):

ref["foo"] = 42
ref["bar"] = "Ni!"



More information about the Python-list mailing list