+ 1

Indexing?

is this just the process of creating a list? they don't explain what indexing is

14th Nov 2016, 8:12 PM
Solace Creat
Solace Creat - avatar
3 Answers
+ 2
Index as in 'pointer or position'. Python uses integer indexes to specify/locate items in a list, and returns them in 'index order'. In lists the first indexed item is at position 0 and items are sequentially numbered; there are no gaps (even when items are deleted). Dictionaries use arbitrary keys as indexes and so are unordered--even if you also use integers. A loop over a dictionary will return items in the order Python chose as most efficient. Because lists have to support reindexing (on changes like 'delete') they are generally slower than dictionaries, which don't care. This seems to be only vaguely explained, relying on understanding this meaning of index.
14th Nov 2016, 8:31 PM
Kirk Schafer
Kirk Schafer - avatar
+ 2
Indexing is in programming very similar to what it means in books. It is a form of measuring elements according to the type of object you are dealing with. E.G.: In lists, the index measures elements, while in strings it measures characters.
15th Nov 2016, 1:55 AM
Gianfranco Gasbarri
Gianfranco Gasbarri - avatar
+ 1
What do you mean about indexing? if you have a list: x = [10, 20, 30, 40, 50] # 5 items you can access it by reference to index, for example: x[3] # is 40 remember, lists on python doesn't have array two-dimensional, as well. Otherwise you can put a list inside on list: x = [10, 20, [30, 40], 50] print(x[2][0]) # is 30 all this is covered in the course...
14th Nov 2016, 8:31 PM
Miguel Barra
Miguel Barra - avatar