1.

What is break, continue and pass in Python?

Answer»
BREAKThe break statement TERMINATES the loop immediately and the control flows to the statement after the body of the loop.
ContinueThe continue statement terminates the current ITERATION of the statement, skips the rest of the code in the current iteration and the control flows to the next iteration of the loop.
PassAs EXPLAINED above, the pass keyword in Python is generally used to fill up EMPTY blocks and is similar to an empty statement represented by a semi-colon in languages such as Java, C++, Javascript, etc.
pat = [1, 3, 2, 1, 2, 3, 1, 0, 1, 3]for p in pat: pass if (p == 0): current = p break elif (p % 2 == 0): continue print(p) # output => 1 3 1 3 1print(current) # output => 0


Discussion

No Comment Found