target = [1, 2, 3, 4, 2, 5, 3]
M = 10
water = 0
count = 0
min = 0

for i in range(len(target)):
    count += 1
    water += target[i]
    if water >= M:
        min = count
        count = 0
        water = 0
        if min < count:
            break
            
print(min)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: