So I have to following code with the goal to add some offset to measurement data.
This works as planned:
IndexMax = [3, 10, 20, 30]
IndexMax2 = [3, 10, 20, 30] #Just for Computing purposes
for x in range(0, len(IndexMax)):
if x == 0:
IndexMax2[0] = 0; #First Data has no Offset per Definition
elif len(IndexMax2) >= 1: #The
IndexMax2[x] = IndexMax[x-1] + IndexMax2[x-1]
tmp = IndexMax2
print('Offsets are ' + str(tmp))
The Correct Output is given:
Offsets are [0, 3, 13, 33]
But what does not work is the same as a funtion with Indexmax as an argument:
def Offsetcalcalculater(IndexMax):
IndexMax = IndexMax
IndexMax2 = IndexMax
for x in range(0, len(IndexMax)):
if x == 0:
IndexMax2[0] = 0; #First Data has no Offset per Definition
elif len(IndexMax2) >= 1: #The
IndexMax2[x] = IndexMax[x-1] + IndexMax2[x-1]
tmp = IndexMax2
return IndexMax2
Calling it with
IndexMaxtest = [3, 10, 20, 30]
IndexMax2 = Offsetcalcalculater(IndexMaxtest)
leads to:
IndexMax2 [0, 0, 0, 0]
Why does the function not behave in the same way as the code above?