In this Tutorial We Will Learn About While Loops In Python, While Loops are the Most Important Part In Python And We Use Loops In Python Do The Tasks repetitively For Example If Someone Says you to Print Your Name For 100 Times, But the Condition You Don’t Have To Write 100 times then We can Use Loops In Python to Perform This Task. So Let’s Start With This Tutorial If You Have Not Accessed The Python Complete Course Access Here:
While Loops is used to Perform Task a Block of Code Repeatedly Until a Condition Is True & Executed. And If the Loop is false the In the Program is Executed Again.
i = 10 while i < 15: print(i) i += 1
10 11 12 13 14
The while loop requires the relevant variables to be available, in this example we need to define an indexing variable, i, which we set to 1.
Break System In Python Stops the Loop When the Given Condition is Satisfied..
i = 5 while i < 6: print(i) if i == 10: break i += 1
With the continue statement, we can stop the current iteration and continue with the next iteration
i = 5 while i < 2: print(i) if i == 6: continue i += 1
1 2 3 4 5
Else Statement Run the Block Of Code Once the Condition is No Longer True.
i = 1 while i < 4: print(i) i += 1 else: print("i is greater than the given number")
Access Complete Python Course Here: