在Python中,比较数字会给出错误的结果

2024-05-19 10:54:49 发布

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

抱歉,如果这是一个可怕的问题,但我真的是新的编程。我正在尝试一个简短的小测试程序。

如果我输入的值小于24,它会打印“Youwillbeold…”语句。如果我输入的值大于24(最多99),它将打印“youarold”语句。

问题是,如果您输入的值大于等于100,它会打印“您将在不知不觉中变老”语句。

print ('What is your name?')
myName = input ()
print ('Hello, ' + myName)
print ('How old are you?, ' + myName)
myAge = input ()
if myAge > ('24'):
     print('You are old, ' + myName)
else:
     print('You will be old before you know it.')

Tags: youinputis编程语句whatoldare

热门问题