I'm having issues determining my maximum value calculated in my for loop. I'm using Python to evaluate an array to determine the maximum delta in a sequence i.e. maximum value i+1-i.
I'm having two issues:
- SyntaxError: 'return' outside function
- I don't know how to pull the largest calculated iterated value from my for loop
Tried having other variables to compare largest values etc
prices=[7,1,5,3,6,4]
profit_loss=0
for i in range(0,len(prices)-1):
profit_loss=prices[i+1] - prices[i]
return(profit_loss)
print(profit_loss)
Maximum value should be 4 and the results of my print are below:
-6
4
-2
3
-2
This question is unique because I am looking to understand why the return function is not necessary.