1Age_of_laochuanzhang = 562Conut =03 whileTrue:4 ifConut = = 3:5 Print("maximum number of inputs")6 Break7age = Int (input ("Please enter your age:"))8 ifAge_of_laochuanzhang = =Age :9 Print("Yes, you got it.")Ten Break One elifAge_of_laochuanzhang >Age : A Print("think smaller ...") - Else: - Print("Think bigger!") theConut +=1
First edition,
The optimized
Age_of_laochuanzhang = 56Conut=0 whileconut< 5: Age= Int (Input ("Please enter your age:")) ifAge_of_laochuanzhang = =Age :Print("Yes, you got it.") Break elifAge_of_laochuanzhang >Age :Print("think smaller ...") Else: Print("Think bigger!") Conut+=1Print("time Out, try again later")
Age_of_laochuanzhang = 56 forIinchRange (5): Age= Int (Input ("Please enter your age:")) ifAge_of_laochuanzhang = =Age :Print("Yes, you got it.") Break elifAge_of_laochuanzhang >Age :Print("think smaller ...") Else: Print("Think bigger!")Print("time Out, try again later")
Python's While loop