I have items in a list. The number of those items depend on user input. What I'm trying to do is to make an equation on first two items (the equation itself doesn't matter here, it produce the result). Then use result of this equation as "first" element of the next equation but with next element etc. to the end of the list. What is the simplest way to do it?
Example:
list = [1,2,3,4,5]
a = list[0]
b = list[1]
result = a + b
here the problem starts:
result = result + list[2]
result = result + list[3]
...
... and so on
I know I can access each element in a list via its index but how to make it go through whole list without specific index?