Dec-31-2021, 01:23 PM
First i did that but i initialized my variable inside de loop. I woke up this morning with the same idea.
Thanks for your reply and solution.
Thanks for your reply and solution.
(Dec-30-2021, 09:28 PM)bowlofred Wrote: You've usedx
as your loop variable, so it is modified each time through the loop. If you want a variable to hold information across each cycle, you need to use a different variable.
On line 24 and 25 you modify and then print x. But when the loop runs again and goes back to line 21, your modifications are lost.
I'm guessing you're trying to do something like this:
total = 0 for x in mlist[-t-1::-1]: print(f"Checking {x} against {add}") if x >= add: break total += x print("stop",total)