Opening Hours :7AM to 9PM
while(condition): ... ... ...In the above syntax if the condition is true the statements of while block is execute infinite times, if the condition is false while block terminated :
def myfun(): x=1 while(x<=10): print(x) x=x+1 if __name__=="__main__": myfun()
def myfun(): x=10 while(x>=1): print(x) x=x-1 if __name__=="__main__": myfun()
Nested While Loop :
One While loop within another While loop is knows as Nested While Loop
Syntax
while(condition): while(condition): ... ... ... ... ... ...In the above syntax :
def myfun(): x=1 while(x<=6): y=1 while(y<=3): print("*",end="") y=y+1 print(end="\n") x=x+1 if __name__=="__main__": myfun()
def myfun(): x=1 while(x<=6): y=1 while(y<=x): print("*",end="") y=y+1 print(end="\n") x=x+1 if __name__=="__main__": myfun()
def myfun(): x=1 while(x<=6): y=6 while(y>=x): print("*",end="") y=y-1 print(end="\n") x=x+1 if __name__=="__main__": myfun()