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.
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
Wow, thanks. That makes a sense.
youāre welcome, itās easy to make typos, especially when learning
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
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
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
mini-miracles erryday, yāall
Me too 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}")