The output is correct. The numbers are index values of the found values in the list, not the values themselves.
You can execute the code in the Python console. See also Easy way to run python script in blender python console?
Here is the data that is read from the file:
>>> readout
[['width', '5'], ['width', '10'], ['width', '2'], ['width', '6'], ['width', '10'], ['width', '9'], ['width', '1'], ['width', '10'], ['width', '7'], ['width', '8']]
In the loop a
is an element of the list:
>>> for a in readout:
... print(a)
...
['width', '5'] # index 0
['width', '10'] # index 1
['width', '2'] # index 2
['width', '6'] # index 3
['width', '10'] # index 4
['width', '9'] # ...
['width', '1']
['width', '10']
['width', '7']
['width', '8']
If you enter readout.index(
and hit the Tab key you will get a short description of the index()
function. It tries to find the given value in the list and returns its index. The index starts at 0
for the first element. If the element is not found you will get an exception (error).
>>> readout.index(
index(value, start=0, stop=9223372036854775807)
Return first index of value.
Raises ValueError if the value is not present.
If you call the index()
function with the element ['width', '10']
(which is a list with the two column values from the file) then you will get its index: 1
>>> readout.index(['width', '10'])
1
If you increase the start index to '2', you will get the next search result: 4
. This is correct.
>>> readout.index(['width', '10'], 2)
4
If you want to see just the numbers, you need to use a[1]
to access the nested list element:
>>> for a in readout:
... print(a[1])
...
5
10
2
6
10
9
1
10
7
8