score=0
def check_guess(guess,answer):
global score
temp=0 #新加的
still_guessing=True #新加的
while still_guessing and temp<3:
if guess==answer:
print("you are right")
score=score+1
still_guessing=False
else:
if temp<2:
print("wrong")
temp=temp+1
if temp==3:
print("the correct answer is %s" % answer)
answer01=input("who is handson?")
check_guess("up",answer01)
================3/26 改
def check_gu(guess,answer):
guessTime=True
temp=0
while (guessTime and temp<3):
print("這是第%d次" % temp)
guess=input("the most handsome is??")
if (guess==answer):
print("right")
guessTime=False
else:
if (temp<2):
print("try it again")
temp=temp+1
if (temp==3):
print("the answer is %s" % answer)
guess01=input("the most handsome is??")
check_gu(guess01,"me")
======4/1 改
def guesswho(guess,answer):
guessing=True
temp=0
while (guessing and temp<3):
print("這是第%d次" % (temp+1))
if (guess==answer):
print("you are right")
guessing=False
else:
if (temp<2):
guess=input("repeat again")
temp=temp+1
if temp==3:
print("the answer is %s" % answer)
guess01=input("who is most smart??")
guesswho(guess01,"up")