a=[1,2,3,4].reverse() - why "a" is None?

Erik Max Francis max at alcyone.com
Mon Oct 12 09:35:12 CEST 2009


Andre Engels wrote:
> The reverse function is a function to reverse the list in place, not a
> function to get the reverse of the list:
> 
> x = [1,2,3,4]
> y = x
> z = x.reverse()
> 
> will result in:
> 
> x = y = [4,3,2,1]
> z = None

.reverse returns None.  See the documentation.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
   Sometimes a cigar is just a cigar.
    -- Sigmund Freud



More information about the Python-list mailing list