I am wondering why in python, when trying:
count = 0
while count < 3:
    for i in range(40):
        count += 1
does not actually check the while loop condition. Whereas in
count = 0
for i in range(40):
    while count < 3:
        count += 1
does. At first I assumed that maybe the while loop has to be ignored until the iterations are complete. But if I run 2 different for loops
count = 0
while count < 3:
    for i in range(40):
        count += 1
    for i in range(40):
        count += 1
The same things happens! count will become 80. I have been using while loops frequently and am surprised I have never encountered this. Does the while loop only get checked at the end of its contents?. If so, how could I write a variation of the first body of code
 
     
    