1.
while x < 3:
print("x%d" % x)
y = 0
while y < 3:
print("y%d" % y)
print("")
y += 1
print("y%d" % y)
print("")
x += 1
print("x%d" % x)
: ()
1
x = 0
y = 0
y = 1
y = 1
y = 2
y = 2
y = 3
x = 1
2
x = 1
y = 0
y = 1
y = 1
y = 2
y = 2
y = 3
x = 2
3
x = 2
y = 0
y = 1
y = 1
y = 2
y = 2
y = 3
x = 3
2.
x = 0
y = 0
while x < 3:
print("x = %d" % x)
while y < 3:
print("y = %d" % y)
print("")
y += 1
print("y = %d" % y)
print("")
x += 1
print("x = %d" % x)
: ()
1
x = 0
y = 0
y = 1
y = 1
y = 2
y = 2
y = 3
x = 1
2
x = 1
x = 2
3
x = 2
x = 3
Why is this difference? After watching the video, the teacher only told me that the difference existed and analyzed the execution process himself, but it was based on the analysis of the results, and he always felt a little confused about the principle.
Is there any clearer way to understand? Like python code from top to bottom, from left to right, LEGB principle?