1def maxProfit(prices): 2 maxProfit = 0 3 4 for i in range(1, len(prices)): 5 if prices[i] > prices[i - 1]: 6 maxProfit += prices[i] - prices[i - 1] 7 8 return maxProfit