There is a cycle called the cycle of death, once triggered, will run an everlasting, lasting.
Lasting code
Count = 0while True: print(" You are the wind I am the sand, tangled up to the horizon ... " , Count) +=1
In fact, in addition to the time, nothing is eternal, dead loop or less write as good
The code above loops out 100 times.
Count = 0while True: print(" You are the wind I am the sand, tangled up to the horizon ... " , Count) +=1 If count = =: print(" go to your mother's wind and sand, you these pants are people, Wearing pants is a ghost of the Smelly Man . " ) break
Back to the example above for the loop, how to enable the user to constantly guess age, but only to give up to 3 times, and then guess the wrong to quit the program
#!/usr/bin/env python#-*-coding:utf-8-*-My_age= 28Count=0 whileCount < 3: User_input= Int (Input ("input your guess num:")) ifUser_input = =My_age:Print("Congratulations, you got it!") Break elifUser_input <My_age:Print("Oops,think bigger!") Else: Print("Think smaller!") Count+ = 1#Each loop counter +1Else: Print("guess it's wrong so many times, you idiot.")
Day1_python base _15.while Loop