Sunday, May 29, 2022

the while loops , break statement,continue statement

 the while loops :

with the while loops we can execute a set of statement as long as condidtion is true 

example:

a = 1

while a < 10:

  print(a)

  a = a+1

output:


the break statement:

i = 1

while i < 6:

  print(i)

  if i == 3:

    break

  i += 1

output:


the continue statement:

i = 0

while i < 6:

  i += 1

  if i == 3:

    continue

  print(i)

  output:




No comments:

Post a Comment