我是 python 新手,但我试图将 DogAge 放入数学方程中,但仍然无法正常工作
Animal = input("dog or cat? ")
if Animal == "dog":
DogAge = int(input("how old is you dog? "))
else:
CatAge = int(input("how old is your cat? "))
if DogAge == 1:
print("your dog's age is 11")
elif DogAge == 2:
print("your dog's age is 22")
else:
print("your dog's age is " + (DogAge - 2 * 4 + 22))
给出:
TypeError:无法将“int”对象隐式转换为str