Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help debugging
#1
My class has been set a task to calculate the ages of cats and dogs.
Here are the requirements -
The Maths
Cats Equivalent Age
The first 2 years equal 25 Human years every additional year  = 4 Human equivalent years
 
Dogs Equivalent Age
First year equal 15 Human years, the second year is equal to 9 Human years, every additional year  = 4 Human equivalent years
 
 
Task:
Create a program that asks for the type and real age of your pet
Then outputs the Equivalent Human Age for your pet
 
Degrees of Challenge:
 
Basic:
Accepts CAT or DOG and outputs the correct EHA answer
Has a simple HCI (Human Computer Interface) that is followable
 
Advanced:
Uses the pets first name
Rejects other spellings and animals eg RAT, Dog
 
Very Advanced:
Accepts spellings such as Dog, DOG, dOg etc 
Accepts Nonwhole years for the real age
Loops until as acceptable input is given
We are using Python 3.5.2
We are using the website called repl.it


I am going for very advanced and my code is getting an error. This is my code.
animalType = input("What sort of animal do have, DOG or CAT? \n>")
animalAge = int(input("How old is your "+animalType+" in whole years? \n>"))
if animalType.lower() == "dog":
    #Dog Calculations
    eHA=0
    if animalAge >=1:
        eHA = 15
    if animalAge >=2:
        eHA += 9
    if animalAge >=3:
        eHA += (animalAge-2)*4
elif animalType.lower() == "cat":
    #Cat Calculations
    eHA=0
    if animalAge >=1:
        eHA = 12
    if animalAge >=2:
        eHA += 13
    if animalAge >=3:
        eHA += (animalAge-2)*4
elif animalType.lower() = ! "dog" or "cat":
    print("I don't know what an",animalType,"is, Sorry")
print("Your animal is...",eHA,"years old")
#Exit
print("Goodbye")
input("Press ENTER to stop the program")
My code is getting this error.
Error:
Traceback (most recent call last):  File "python", line 21    elif animalType.lower() =! "dog" or "cat":                            ^ SyntaxError: invalid syntax
I don't know how to fix or what the problem even is. Please Help!
Thank You!
Reply


Messages In This Thread
Need help debugging - by SyntaxError123 - Mar-26-2017, 04:35 PM
RE: Need help debugging - by nilamo - Mar-26-2017, 05:25 PM
RE: Need help debugging - by SyntaxError123 - Mar-26-2017, 05:41 PM
RE: Need help debugging - by Larz60+ - Mar-26-2017, 06:59 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020