为什么定义中断代码时while循环失败了?

2024-09-23 22:30:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我是Python新手,正在探索一个简单的辅助项目,以了解函数和循环是如何工作的。你知道吗

我这里有密码

age = 0

def ageInMonths (age):
    months =  int(age) * 12
    return print('You are ' + str(months) + ' months old!')

def ageInDays(age):
     days = int(age)*365
     return print('You are ' + str(days) + ' days old!')

def ageInHrs(age):
    hrs = int(age)* 8765.81
    return print('You are ' + str(hrs) + ' hours old!')

    def ageinMin(age):
       minutes = int(age)* 525948.8
       return print('You are ' + str(minutes) + ' minutes old!')

    def ageinSec(age):
       sec= int(age)* 31556926
       return print('You are ' + str(sec) + ' seconds old!')


def agePrint(age):
    age=age
    ageInMonths(age)
    ageInDays(age)
    ageInHrs(age)
    ageinMin(age)
    ageinSec(age)
      print('Done')
    return 

while age != 99:

    print( 'Please enter your age?')

    age = input()
    if age == 99:
     break


    print('You are ' + age + ' years old!')


    agePrint(age)

每次输入99,while循环都不会中断。任何关于我哪里出错的建议。。你知道吗


Tags: youagereturndefdaysoldareint