Addressing the last element of a list

pinkfloydhomer at gmail.com pinkfloydhomer at gmail.com
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
idea

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

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

etc.

/David




More information about the Python-list mailing list