+ 4
What are arbitrary indices ?
Can't understand the meaning of this term.
2 Answers
+ 9
Go to the List Slices chapter in the Python tutorial. The comments at the fourth (4th) slide are explaining arbitrary or secondary indexing rather well.
In short, arbitrary indexing is a way to refer to an element of, i.e. a string, by not using regular indexing.
i.e. say you have a string blah = "ABCDE"
blah[1] --> B
blah[0] --> A
blah[-1] --> E (-1 takes me to the end of the string)
blah[-2] --> D
and so on and so forth
Other uses are in slicing.
blah[1:]--> BCDE
blah[1:3]--> BC
blah[::-1] reverses the order of the string
Check the comments in the slide mentioned above and if you need more info, let us know.
+ 1
@AG Hahaha.. Well, I shall not answer, thus enhancing the mystery..