The equivalent function for the element selection operator is called getitem , and it also uses 0-indexed positions to select elements from a
list.
If you want to change selection, open document below and click on "Move attachment"
2.2 Data Abstractionexed, meaning that the index 0 selects the first element, index 1
selects the second, and so on. One intuition that supports this indexing
convention is that the index represents how far an element is offset from the
beginning of the list.
<span>The equivalent function for the element selection operator is called
getitem , and it also uses 0-indexed positions to select elements from a
list.
>>> from operator import getitem
>>> getitem(pair, 0)
10
>>> getitem(pair, 1)
20
Two-element lists are not the only method of representing pairs in Pyth Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details