I am providing two values (mon_voltage and core_voltage) through command line, and I need to search a 'start point' from a two dimensional array from where my iteration or loop will start.
Here is my code:
myArray = [[1.02,1.13],[1.02,1.16],[1.02,1.18],[1.02,1.21],[1.02,1.265]]
start_point = myArray.index([mon_voltage, core_voltage])
print "Start point is", start_point
for idx in enumerate(myArray):
mon_voltage = myArray[idx + start_point][0]
core_voltage = myArray[idx + start_point][1]
I am getting the following error:
TypeError: can only concatenate tuple (not "int") to tuple
I am unable to figure out why start_point, which is an index, is a tuple. Please help.
The
enumerate()
will return a(index, value)
tuple.You can access the index value as
Example
OR
Here the tuple is unpacked to
idx
andvalue
and we use theidx
for following logic what so ever may occur within thefor
loop.The
value
will contain the value at index positionidx
that ismyArray[idx]