[Tutor] Array slices in python with negative step
dextrous85 at gmail.com
Mon Jan 11 21:07:31 CET 2010
On Tue, Jan 12, 2010 at 1:16 AM, Alan Gauld <alan.gauld at btinternet.com>wrote:
> "vishwajeet singh" <dextrous85 at gmail.com> wrote
> Thanks for your response but I am still not clear; can you show me the
>> equivalent of [::-1] in terms actually specifying start-index, end-index
>> which gives me reverse of the given arrary.
> I don't think you can, you must use the empty value.
> In theory you could use -1 except of course -1 refers to the 'e'...
> Its a slight anomoly due to the use of negative indexing. You
> can do:
> and get the same as [0:]
> But you cannot put any valid value for x in
> 'abcde[4 : x :-1]
> that gets you the full string. You need to use [4::-1]
Thanks Alan and Micheal that surely cleard my doubts.
+91-9657702154 | dextrous85 at gmail.com | http://singhvishwajeet.com
Twitter: http://twitter.com/vishwajeets | LinkedIn:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor