Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help fixing my code. IN PYTHON 3. I keep getting an attribute error after a couple inputs. I dont know what i'm doing

I need help fixing my code. IN PYTHON 3. I keep getting an attribute error after a couple inputs. I dont know what i'm doing wrong. the code and output is below.
image text in transcribed
image text in transcribed
image text in transcribed
Current file: main.py Load default template... 2 # Create your main code here 5. Import pet 7 pet_owner - input("Please enter owner's name:") 3 pet.Pet.pet_owner - pet owner 9 pet list - 10 while True! pet name input("Please enter the pet's nan") if pet_name= "qor pet_name " : break age - int (input("Please enter the pet's age")) pet - pet.Pet(pet_name, age) pet list.append(pet) 17 print("Pet List:) 18 for pet in pet_list print (pet) Current file: pet.py Load default templat 2 # Create your pet class here 3 4 class Pet: pet_owner - "X" 10 def __init_(self, name, age): self.pet_name - name self.pet_age - age def_str__(self): var - "(0) is (1) year(s) old and is owned by (2)". format(self.pet_nane, self.pet_age, Pet.pet_owner) return var 6: Compare output A 0/1 Output differs. See highlights below. Sam I am Good Boi Input Jackson Your output ends with s agePlease enter the pet's namePlease enter the pet's ageTraceback (mos File "main.py", line 15, in pet - pet. Pet (pet_name, age) AttributeError: Pet' object has no attribute 'Pet! Expected output ends with Pet List: Good Boi is 5 year(s) old and is owned by Sam I am Jackson is 7 year(s) old and is owned by Sam I am

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions