While loop
#第50次不打印, 第60-80次 prints the square of the corresponding value
1Count =02 3 whileCount <= 100:4 ifCount = = 50:5 Pass6 elifCount >= 60 andCount <=80:7 Print(count*count)8 Else:9 Print("Loop", Count)Ten OneCount + = 1 A - Print("------Loop is ended-------")
Dead loop (Dead Loop)
Count = 0 while true:#true itself is true print(" Forever-------", Count) + = 1
Break is used to completely end a loop, jumping out of the loop body to execute the statement behind the ring continue just terminates the loop, then executes the loop behind it.
count = 0 while count <= 100: print (" Span style= "COLOR: #800000" >loop " ,count) if count = = 5: break count + = 1print ( Span style= "COLOR: #800000" > " ------out of loop------- " )
Count = 0 while Count <=: print("", Count) if count = =5 :continue + = 1print ("------out of loop-------")
0-100 loops, skipping 6 to 94
Count = 0 while Count <=: + = 1 if and Count <: continue print("", Count)Print ("------out of loop-------")
Fifth day Python learning record