Day 064 - Project 64 : Jobs in a school

If you have any questions, comments or issues with this project please post them here!

I’m actually having issues once I get to the Inheritance slide with the part about polly = bird(ā€œGreenā€) and the self.color = color.

1 Like

Could you explain these issues?

class bird(animal):

  def __init__(self):
    self.name = "Bird"
    self.species = "Avian"
    self.sound = "Tweet"
    self.color = color # Only applies to the bird sub class


polly = bird("Green") # Sets polly's colour to 'Green'
polly.talk()
print(polly.color) # Prints polly's color

This is the code given in the example (the part I’m having issues with)

This is the error I’m getting: TypeError: __init__() takes 1 positional argument but 2 were given

class bird(animal):

  def __init__(self, color):
    self.name = "Bird"
    self.species = "Avian"
    self.sound = "Tweet"
    self.color = color # Only applies to the bird sub class


polly = bird("Green") # Sets polly's colour to 'Green'
polly.talk()
print(polly.color) # Prints polly's color
1 Like

Wow, thanks. That makes a sense.

you’re welcome, it’s easy to make typos, especially when learning :smiley:

It doesn’t explain it in the lesson though. What I pasted here was from the lesson portion of it. I do understand though that some of the learning is probably intended to be figuring things out.

mhm, yeah I can see that being a problem, you should perhaps ping DavidAtReplit and make a support ticket for confusing lessons

Will definitely keep that in mind. Thanks a bunch for the help with this.

You’re welcome! Have a nice day

yeah and in the ā€œfix my codeā€ the answer is not working, the talk() is missing and the color attribute is not handled right. so @DavidAtReplit should maybe review his answer and correct it :slight_smile:

1 Like

I had a lot of challenges with this day

BUT

I will share, for posterity, my miracle cure that I will (now) continue to use.

Here, fellow learners, is my miracle ChatGPT prompt for this lesson:

INSTRUCTIONS: Help me with my assignment by asking questions. DO NOT GIVE ME THE ANSWERS.

Assignment = {{
~INSERT Day 64 CHALLENGE TEXT HERE~
}}

My Current Code = {{
~INSERT WHATEVA YA GOT / CURRENT CODE HERE~
}}


The magic of finding my own way through the maze… feeding ChatGPT this prompt… Well…

tips hat

I’ve been longing to understand the basics of OOP for so long… sigh of relief

2 Likes

Have you looked into Corey Schafer’s youtube series on OOP?

@EmeraldMoss , I have not! So, thank you for the hot tip. I’ll be checking Corey’s channel out after watching a short video from him.

tips hat
:raised_hand_with_fingers_splayed: :cowboy_hat_face:

mini-miracles erryday, y’all :sparkles:

Me too :confused: it keeps saying that ā€˜bird’ object has no attribute ā€˜color’ but thanks for the help now!

Actually rolling the video on, I can see at ~8:00 I can see that David adds the additional str elements.

Note to self: watch it twice before shouting!

I’d actually done this already in one way or another:

blackbird = bird("green")
blackbird.talk()

print(f"The {blackbird.color} {blackbird.name} says {blackbird.sound}")
1 Like