5 967
订阅者
无数据24 小时
-357 天
-22530 天
帖子存档
5 967
CONTINUE STATEMENT WITH FOR LOOP
We can use the continue statement with the for loop to skip the current iteration of the loop. Then the control of the program jumps to the next iteration. For example,
5 967
CONTINUE STATEMENT WITH FOR LOOP
We can use the continue statement with the for loop to skip the current iteration of the loop. Then the control of the program jumps to the next iteration. For example,
5 967
CONTINUE STATEMENT
The continue statement is used to skip the current iteration of the loop and the control flow of the program goes to the next iteration.
The syntax of the continue statement is:
continue5 967
BREAK STATEMENT WITH WHILE LOOP EXAMPLE
We can also terminate the while loop using the break statement. For example,
5 967
BREAK STATEMENT WITH FOR LOOP EXAMPLE
We can use the break statement with the for loop to terminate the loop when a certain condition is met. For example,
5 967
BREAK STATEMENT
The break statement is used to terminate the loop immediately when it is encountered.
The syntax of the break statement is:
break5 967
PASS STATEMENT EXAMPLE
for letter in 'Rushi':
if letter == 'n':
pass
print('This is pass block')
print('Current Letter :', letter)
print("Good bye!")
Output:
Current Letter : R
Current Letter : u
Current Letter : s
This is pass block
Current Letter : h
Current Letter : i
Good bye!5 967
PASS STATEMENT
As the name suggests pass statement simply does nothing.
The pass statement in Python is used when a statement is required syntactically but you do not want any command or code to execute.
It is like null operation, as nothing will happen is it is executed.
Pass statement can also be used for writing empty loops.
Pass is also used for empty control statement, function and classes.
5 967
NESTED LOOP
A nested loop is a loop inside a loop. The "inner loop" will be executed one time for each iteration of the "outer loop":
5 967
WHILE LOOP EXAMPLE 2
In this example, we will use the while loop for printing the multiplication table of a given number.
