Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python While Loop Condition Evaluation

Say I have the following loop:

i = 0
l = [0, 1, 2, 3]
while i < len(l):
    if something_happens:
         l.append(something)
    i += 1

Will the len(i) condition being evaluated in the while loop be updated when something is appended to l?

like image 794
Allan Lavell Avatar asked Dec 12 '25 20:12

Allan Lavell


1 Answers

Yes it will.

like image 174
Dario Avatar answered Dec 15 '25 08:12

Dario



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!