FAQ: Learn Python: Inheritance and Polymorphism - Review

This community-built FAQ covers the “Review” exercise from the lesson “Learn Python: Inheritance and Polymorphism”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science

FAQs on the exercise Review

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

3 posts were split to a new topic: Bonus Challenge Discussion

8 posts were split to a new topic: When do I need to use super()?

13 posts were merged into an existing topic: Bonus Challenge Discussion

A post was merged into an existing topic: Bonus Challenge Discussion

5 posts were split to a new topic: Fixing my code

6 posts were merged into an existing topic: When do I need to use super()?

Hello family, please I am lost again with this code:

`
class SortedList(list):

def init(self, lst):
self.lst = lst
super().init(lst)
self.sort()

def append(self, value):
super().append(value)
self.sort()

def str(self, lst):
return 'why all these complications with classes. {} '.format(self.lst)

x = SortedList([4, 1, 5])

print(x)

`

please tell me what is wrong with these code. First of all, I defined a str function in the SortedList class, hoping to print something. BY “format(self.lst)”, I was hoping to print the sorted list of any instance of the SortedList class.

secondly, I didn’t get the whole gist of the “super()” stuff and the dunder methods that we can build ourselves… because in it, we still use python built in object . by defining a dunder method ourselves, for example anxiety(), are we trying to overide a similar python built-in method or totally creating something that will behave like that particular built in method?
please help me explain these with maybe one good example to illustrate. thanks.