return the last item in a list

Erik Max Francis max at alcyone.com
Wed Mar 30 23:34:31 EST 2005


Raymond Hettinger wrote:

>> I'm looking for an 'easy' way to have the last item in a list returned.
> 
> Try mylist.pop() or mylist[-1].

Note that list.pop also removes the last element from the list in the 
process.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Granted that I must die, how shall I live?
   -- Michael Novak



More information about the Python-list mailing list