python 基础之猜年龄游戏

'''
需求:
一、可猜三次
二、三次猜完可选择是否继续
'''


age_of_Clyde = 25
count = 0while count < 3:    #输入默认是字符串类型,转换成int类型    age_of = int(input('age_of_Clyde:'))    if  age_of == age_of_Clyde :        print('输入的年龄为:',age_of,'\n正确')        break  #跳出循环;continue 为跳出单次循环,继续下一次循环    elif age_of > age_of_Clyde:        print('输入的年龄为【%s】大于实际年龄'%(age_of))    else:        print('输入的年龄为【%s】小于实际年龄'%(age_of))    count +=1    if count ==3:        age = input('输入n继续,不然退出')        if age != 'n':            print('游戏结束')            break        else:            count = 0
相关文章
相关标签/搜索