程序未打印

  • 本文关键字:打印 程序 python
  • 更新时间 :
  • 英文 :


我写了这个程序,但是当我打印它时它没有执行:

age= int(input("How old is your dog?"))
if age>0:

print("Please input positive number")
elif age<=2:

dage= age*10.5
else age>2:

dage=21+((age-2)*4)
print("The dog is", dage, "years old")
print(age)

要使它运行,我缺少什么?

我认为你想要取消缩进条件语句。我认为你的条件语句也需要一些工作-我已经更新了一点。见下文.


age = int(input("How old is your dog?" ))
dage = 0
if age < 0:
print("Please input positive number")
elif age <= 2:
dage = age*10.5
else:
dage = 21+((age-2)*4)
print("The dog is", dage, "years old")
print("age", age)

最新更新