python实现猜年龄游戏

很简单的小游戏;要求是用户自己定义一个年龄,可以在键盘上输入,然后猜测这个年龄,如果小于就提示输入过小,如果大于就提示大于,直到输入正确的年龄,就会自己退出
boy_age = input(‘please input your want to guess age number’)
print(‘please guess the boy age.and i will return your true or false’)
while True:
guess_age = input(‘your guess age is:’)
if int(guess_age) < int(boy_age):
print(‘too low’)
elif int(guess_age) > int(boy_age):
print(‘too heigh’)
else:
print(‘your guess is true’)
break

猜你喜欢

转载自blog.csdn.net/weixin_43797908/article/details/84674035