For the l in [1, 9, 0] :
If l % 3==0:
Print (" if ")
Break
The else:
Print (" else ")
Print (l)
Print (" -- -- -- -- -- -- -- -- use the else: no if -- -- -- -- -- -- -- -- ')
The for m in [1, 9, 0] :
Print (" for ")
Break
The else:
Print (" else ")
Print (m)
Why would the second situation to the Unresolved Reference 'm'
CodePudding user response:
Using the else for a while loop, it is in the for while statement will perform when running normally, or we will not perform the else 'Is if there was running else if statement,
CodePudding user response:
To recycle the else is not call when break out of circulation, otherwise you will callIf use the else is call when the if is false
CodePudding user response:
Indentation, indentation is wrong, the second the else if without corresponding?CodePudding user response:
See you later wrote a blog post, the hope can help you/Python for or while loop else after the use ofhttps://blog.csdn.net/ftimes/article/details/106753286
I tested your code, is thought to be a wide upstairs, code no problem, should be the cause of the compiler;
3.6.5, IDLE without prompt, PyCharm inside red line, but can be normal operation;
Guess because PyCharm compiler think m and it should be recycled...
As to why l don't red line, presumably because l marked yellow line in the for...
In the tutorial is written in the else? This part of the print (m) and print (l) should write may be thus the author original intention (:
CodePudding user response:
'm'The for m in [1, 9, 0] :
Print (" for ")
Break
Only defined in this section, there is no defined elsewhere
CodePudding user response:
And l has defined in the followingFor the l in [1, 9, 0] :
If l % 3==0:
Print (" if ")
Break
The else:
Print (" else ")
Print (l)
CodePudding user response:
Normal end of for loop, the else statement execution, if it is break,, not executed