I was trying to loop over a list in python using the indices but it drops error. Can you guys help me out with this? What could be the syntax that could fix this ?
abs = [10,20,40]
for i in abs:
new_abs = abs[i]+ abs[i+1]
print(new_abs)
So, i have managed to use hard code for the temporary use.
abs = [10,20,40]
new_abs = [ abs[0], abs[0]+ abs[1] , abs[1]+abs[2] ]
print(new_abs)
Can you please, let me know the proper syntax to loop over this index numbers?