Home > other >  Python code for loop problem
Python code for loop problem

Time:10-18

# need to guess the age of the Sun's girlfriend.
# middle right at a time, any games end
# wrong 3 times, ask whether to continue to,
# if you continue, can continue to guess three times, this cycle;
# if stopped, the game out;
 
#! The/usr/bin/env python
# - * - coding: utf-8 - * -
# Author: Bell Sun

Age_of_Sun_gf=25
I=0
Print (type (I))
For I in range (4) :

Guess_age_of_Sun_gf=int (input (" both Please input Bell Sun 's girlfriend age: "))
If age_of_Sun_gf==guess_age_of_Sun_gf:
Print (" Your guess is right!" )
Break
Elif age_of_Sun_gf & lt; Guess_age_of_Sun_gf:
Print (" Your guess is too big!" )
The else:
Print (" Your guess is too low!" )
Print (" I=", I)
While I==3:
Guess_continue=input (" if you want to continue the guess, both please don 't press' n '.
")Print (" this ")
If guess_continue!='n' :
I=0
Print (" I=", I)
The else:
Print (" See you next time!" )

CodePudding user response:

I think while outside to decide whether to end the game, and then use a number of flag judgment
  • Related