[Tutor] infinite while loop
Leam Hall
leamhall at gmail.com
Sat Oct 2 06:14:52 EDT 2021
I put the following line right under the while loop, and at the same indentation as the for loop:
print("In while, the previous balance is: {}.".format(previousBalance))
Maybe give that a try and see what it tells you?
Leam
On 10/2/21 4:13 AM, Marcus Lütolf wrote:
> Thank you.
> The previousBalance is set back to 1000 after each run oft he for loop intentionally for the
> following for loops should run with minimumFixedMonthlyPayment each time increased by 10
> til previousBalance get's negative.
>
> The while loop should then stop, when previousBalance gets smaller than 0 but it doesn't.
> Might it be a problem of scope ?
>
>
> -----Ursprüngliche Nachricht-----
> Von: Susana <lists at linguarum.net>
> Gesendet: Freitag, 1. Oktober 2021 20:47
> An: marcus.luetolf at bluewin.ch
> Cc: tutor at python.org
> Betreff: Re: [Tutor] infinite while loop
>
> Hi,
>
> "previousBalance" reaches while condition (< 0.0) inside the for loop, but then it is set to the value of "balance" in the line:
>
> previousBalance = balance
>
> So I think that "previousBalance" is always 1000 when the while condition is checked.
>
> Hope this helps.
>
> Cheers,
>
--
Systems Programmer (reuel.net/resume)
Scribe: The Domici War (domiciwar.net)
General Ne'er-do-well (github.com/LeamHall)
More information about the Tutor
mailing list