For the python question this afternoon, simply summarize.
Several for nested loops written to themselves, adding if and else always have no results. The reason is that in Python, the For statement is also supported for else. When if else. What was the situation like when they all appeared? As a small example:
For a in range (4):
for B in range (4):
if b >=2:
print ' b=> ', b
else:
print ' a+b=> ', A+b
If a<=2:
print ' a,b=> ', a,b
else:
print ' a,b,b,a=> ', a,b,b,a
Our intention is: first internal for loop, for b ..., and then execute if a<=3 ... the following statement: Execution result:
a+b=> 0
a+b=> 1
b=> 2
b=> 3
a,b=> 0 3
a+b=> 1
a+b=> 2
b=> 2< C19/>b=> 3
a,b=> 1 3
a+b=> 2
a+b=> 3
b=> 2
b=> 3
a,b=> 2 3
a+b= > 3
a+b=> 4
b=> 2
b=> 3
a,b,b,a=> 3 3 3 3
From the end result, we can get that the last else statement belongs to the For statement. (the statement that belongs to the first occurrence)