 # Python while Loop :

### The while Loop :

With the while loop we can execute a set of statements as long as a condition is true.

#### Example :

 ``` i = 0 print("While loop example:\n") while i < 8: print(i) i += 1 input() ```

#### Output : ### while loop with Statements :

With the break statement we can stop the loop even if the while condition is true and the continue statement we can stop the current iteration, and continue with the next.

#### Example 1 :

 ``` x = 0 while x < 8: print(x) if x == 4: break #Exit the loop when i is 4 x += 1 input() ```

#### Output 1 : #### Example 2 :

 ``` y = 0 while y < 8: y += 1 if y == 4: continue #Continue to the next iteration if i is 4 print(y) input() ```

#### Output 2 : ### Nested while loops :

A nested loop is a loop inside a loop. The "inner loop" will be executed one time for each iteration of the "outer loop".

#### Example 1 :

 ``` n = 10 x = 10 y = 0 while x < 20: while y < n: print("\n",y,end="") y+=1 print("\n",x,end="") x+=1 input() ```

#### Output 1 : #### Example 2 :

 ``` n = 10 x = 10 y = 0 while x < 20: while y < n: print("\n",x,"+",y,"=",x+y,end="") y+=1 x+=1 input() ```

#### Output 2 : 