Categories: PythonWhile statement

while loop with continue break and pass

while loop with continue, break and pass

In this tutorial, we will discuss the concept of while loop with continue, break and pass.

While loop aids with repeating tasks in an efficient manner.
In python, pass, continue and break statements can be used in while loops.

While loop with the pass statement

We can use the pass statement to write empty loops. Pass is also used to empty control loops, function and classes. The pass statements is a null operation, nothing happens while it executes.

Program 1

When the above code is executed, it produces the following results
Display error massage
Program 2

When the above code is executed, it produces the following results

No error massage and no output

Program 3

When the above code is executed, it produces the following results

0
1
2
3
4
5

program 3

When the above code is executed, it produces the following results

var is==3

While with continue statement

The continue statement is used in a loop to take the control to the top of the loop without executing the rest of the statements inside the loop.

program 1

When the above code is executed, it produces the following results
error
program 2

When the above code is executed, it produces the following results

No error and no output

Program 3

When the above code is executed, it produces the following results

1 2 4 5 6 7 8

While  with the break statement

The break statement in python is used to terminate the execution of the current loop.

Program 1

When the above code is executed, it produces the following results.
error
Program 2

When the above code is executed, it produces the following results

No error and no output

Program 3


When the above code is executed, it produces the following results

1 2 3

 

Similar post

for loop with pass break continue statements

Pass statement in Python

continue statement in puthon

break statements in Python

Continue statements in C language

break statements in C language

Karmehavannan

Recent Posts

Using function or method to Write temperature conversion : Fahrenheit into Celsius

Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…

11 months ago

Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user

Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…

11 months ago

Write temperature conversion program: Fahrenheit into Celsius

Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…

11 months ago

How to write a program to convert Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius In this article, we will…

11 months ago

Function/method to convert Celsius into Fahrenheit -Entered by user

Function/method to convert Celsius into Fahrenheit -Entered by user In this article, we will discuss…

11 months ago

Temperature conversion: Celsius into Fahrenheit using function or method

Temperature conversion: Celsius into Fahrenheit using a function or method In this article, we will…

11 months ago

This website uses cookies.