What meaning is 'a[0:10:2]'?

fl rxjwg98 at gmail.com
Sun Nov 15 19:27:03 EST 2015


hi,

When I learn slice, I have a new question on the help file. If I set:

pp=a[0:10:2]

pp is array([1, 3])

I don't know how a[0:10:2] gives array([1, 3]).

I know matlab a lot, but here it seems quite different. Could you tell me
what meaning a[0:10:2] is?


Thanks,



class slice(object)
 |  slice(stop)
 |  slice(start, stop[, step])
 |  
 |  Create a slice object.  This is used for extended slicing (e.g. a[0:10:2]).



More information about the Python-list mailing list