Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help fixing my code. IN PYTHON 3. I have two seperate files: main.py and pet.py. I imported pet into main, so I could

I need help fixing my code. IN PYTHON 3. I have two seperate files: main.py and pet.py. I imported pet into main, so I could use my Pet class. But when I run it, it says "Pet" is not defined. pictures of code and error screen are below. image text in transcribed
image text in transcribed
image text in transcribed
Current file: main.py Load default template... 1 2 #Create your main code here 5 import pet 7 pet_owner - input("Please enter owner's name :") 8 Pet. pet owner - pet owner 9 pet_list - Il 10 while True: pet_name - input("Please enter the pet's nane") if pet_name - 'q' or pet_name -- 'Q: break age - int(input("Please enter the pet's age")) pet - Pet (pet name, age) pet list.append(pet) 17 print("Pet List:) 18 for pet in pet list: 19 print (pet) 13 Current file: pet.py - Load default template... 1 2 - Create your Pet class here class Pet: pet owner - "X" def __init_(self, name, age): self.pet_name = name self.pet_age - age def str (self): var - "{@) is {1} year(s) old and is owned by (2)".Format(self.pet_name, self.pet_age, Pet.pet_owner) return var Compare output Output differs. See highlights below. Sam I am Good Boi Input Jackson Your output ends with enter owner's name : Traceback (most recent call last): File "main.py", line 8, in Pet.pet_owner - pet_owner NameError: name 'Pet' is not defined 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

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What other solution methods did we consider in this chapter?

Answered: 1 week ago

Question

define the term outplacement

Answered: 1 week ago

Question

describe the services that an outplacement consultancy may provide.

Answered: 1 week ago