Having trouble with my code Python3 The output should be like this but I keep ge
ID: 3744163 • Letter: H
Question
Having trouble with my code Python3
The output should be like this but I keep getting errors on every elif statement.
Input: 4 dog medium
Output:
How old is your pet?
What type of animal is your pet?
What size of dog do you have?
Your Medium Dog is 4 year(s) old.
That is 39 in human years.
When I just make them if statements it runs but it doesn't output what I want.
# Enter solution here
age = int(input("How old is your pet?"))
type= input(" What type of animal is your pet?")
print()
if (type == "cat") or (type == "Cat"):
print (" Your Cat is",age,"year(s) old.")
print("That is",(age*4+15),"in human years.")
elif (type == "Dog") or (type == "dog"):
size = input("What size of dog do you have?")
print()
print ("Your dog is",age,"year(s) old.")
if (size == "Small") or (size == "small"):
print("Your ",size," Dog is ",age,"year(s) old.")
print("That is ",(age*4+20)," in human years.")
if (size == "Medium") or (size =="medium"):
print("Your ",size," Dog is ",age,"year(s) old.")
print("That is ",(age*6+15)," in human years.")
if (size == "Large") or (size == "large"):
print("Your ",size," Dog is ",age,"year(s) old.")
print("That is ",(age*9+4)," in human years.")
else :
print ("I'm sorry I don't know what a ",type," Dog is.")
Explanation / Answer
# Enter solution here age = int(input("How old is your pet?")) type = input("What type of animal is your pet?") if (type == "cat") or (type == "Cat"): print(" Your Cat is", age, "year(s) old.") print("That is", (age * 4 + 15), "in human years.") elif (type == "Dog") or (type == "dog"): size = input("What size of dog do you have?") if (size == "Small") or (size == "small"): print("Your Small Dog is", age, "year(s) old.") print("That is", (age * 4 + 20), " in human years.") if (size == "Medium") or (size == "medium"): print("Your Medium Dog is", age, "year(s) old.") print("That is", (age * 6 + 15), "in human years.") if (size == "Large") or (size == "large"): print("Your Large Dog is", age, "year(s) old.") print("That is", (age * 9 + 4), "in human years.") else: print("I'm sorry I don't know what a ", type, " Dog is.")
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.