If I just want Python to print the value in a certain index position in list how do I do it?
This is not giving me what I want:
numbers = [2, 4, 6, 8]
print ([0])
print(numbers[0])
If you don't mention the name, how it will know from which list (there may be plenty) :-)
Right now you just print list with one element
I think I got it.
numbers[2]
As a bit of an explainer on indexing:
position: | 0 | 1 | 2 | 3 | 4 |
data: | a | b | c | d | e |
- position: | -5 | -4 | -3 | -2 | -1 |
The above shows how any indexed object (of which a list object is one example) can be accessed.
For example:
list_data = ['a', 'b', 'c', 'd', 'e']
string = 'abcde'
... to name but two.