The python while loop allows a part of the code to be executed until the given condition return false.
I python we use following loop control statements:
- Continue Statements
- Break Statements
- Pass Statements
Table of Contents
Basics of while loop in python
Syntax of while loop
while expression:
Statements
i=1
while(i<=10):
print(i)
i=i+1
###output
1,2,3,4,5,6,7,8,9,10
Basics of while loop in c
Syntax of while loop
while(Condition){
Statements}
#include<stdio.h>
int main()
{
int i=1;
while(i<=10)
{
printf("%d",i);
i++;
}return 0;
}
In this program we declared i variable inside the main function and use while loop condition.