[Tutor] What exactly is [::-1]?

cuell cuell at math.usask.ca
Thu Jul 26 05:32:20 CEST 2007

In order to reverse the order of an array, I discovered that I'm 
supposed to use [::-1]. 

 >>> a = array([1., 2., 3.])
 >>> a
array([ 1.,  2.,  3.])
 >>> a[::-1]
array([ 3.,  2.,  1.])

I would like to know what exactly the index notation of [::-1] is, where 
it comes from and if there are other variants.

Thank you for your help.  I lurk about on this list and have learned a 
fair bit.

Charles Cuell
cuell at math.usask.ca

More information about the Tutor mailing list