I want to be able to execute the following code:
for i in range(len(b)):
for i in range(6):
File "<ipython-input-982-3ba4e617a74a>", line 1, in <module>
ValueError: could not convert string to float: 'z[i-1]'
eval which is highly discouraged in production code, You can just as easily define a function that returns a specific item based on the array and index:
def k(arr,idx): return arr[idx-1] for i in range(len(b)): z[i]= k(z,i)
If this rule needs to be applied in various spots in your code then you can edit the one function to apply that logic in all the places it is needed.