python_8_guess
#python3和2都可以 #方法1 age_of_oldboy=56 count=0 while True: if count==3: break guess_age=int(input('guess age:')) if guess_age==age_of_oldboy: print('yes,you got it.') break#结束整个循环 elif guess_age>age_of_oldboy: print('think smaller...') else: print("think bigger!") count+=1 #方法2 age_of_oldboy=56 count=0 while count<3: guess_age=int(input('guess age:')) if guess_age==age_of_oldboy: print('yes,you got it.') break#结束整个循环 elif guess_age>age_of_oldboy: print('think smaller...') else: print("think bigger!") count+=1 if count==3: print('you have tried too many times,fuck off') #方法3 age_of_oldboy=56 count=0 while count<3: guess_age=int(input('guess age:')) if guess_age==age_of_oldboy: print('yes,you got it.') break#结束整个循环 elif guess_age>age_of_oldboy: print('think smaller...') else: print("think bigger!") count+=1 else: print('you have tried too many times,fuck off') #python2是可运行的,不需要转换成整数 age_of_oldboy=56 guess_age=input('guess age:') if guess_age==age_of_oldboy: print('yes,you got it.') elif guess_age>age_of_oldboy: print('think smaller...') else: print("think bigger!")