WHILE LOOP😇😇

Python program to demonstrate how the while loop is working. The difference between while and for loop is that for loop applied on every item of list , while loop applied till condition is true.

Flow chart of while loop

Suppose,you has to display number less than 5. so,how will you describe?

1. The starting number

2. The last number

3. Increments in number

# initial number

number = 0

# number less than 5 executed.

while number < 5:
number+=1
print(number)

Output:

1

2

3

4

5

*** you are supposing how the number 5 has come ?

Basically,it is number 4 . in number 4 increment has done . So it becomes 5. ***

Leave a comment