Control Structure-Repetition: Using Decrement or Increment
Control Structure-Repetition: Using Decrement or Increment
• condition is evaluated
– if true, then statement is executed, and
expression is evaluated again
– if false, then the the loop is finished and
program statements following statement
execute
The Logic of a while Loop
How the while loop work
Test this condition
number = 1
number = 6
while number <=5:
print ("Hello")
number+=1
print (“Complete”)
Watch Out for Infinite Loops
number = 1
print (“Complete”)
Using the while Loop for
Input Validation
• Input validation is the process of inspecting
data that is given to the program as input and
determining whether it is valid.