FAQ: Stacks: Python - Stacks Python Size I


#1

This community-built FAQ covers the “Stacks Python Size I” exercise from the lesson “Stacks: Python”.

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

Computer Science

Linear Data Structures

FAQs on the exercise Stacks Python Size I

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

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!


#2

Hello again!

I am working on step one of this exercise and can’t seem to get it right but I don’t want to look at the solution because the last time I did that on another exercise it wouldn’t let me try the exercise again and I learned nothing.

class Stack:
def init(self, size, limit=1000):
self.top_item = None
self.size = 0
self.limit = limit

This is my dunder init, but it keeps asking if I put “limit” as a parameter. If I take out the “=1000” it recognizes the parameter, but then asks if I set the default to 1000. I tried changing it in properties to 1000 but it says I need to set the default in the () of init. I have tried every variation I can think of and just can’t get it to work. Thanks for any help!


#3

Hello,

You probably already got it, but for anyone looking at this in the future, here’s the code:

class Stack:
def init(self, limit=1000):
self.top_item = None
self.limit = limit
self.size = 0

Not sure why we don’t put ‘size’ in the brackets, but it worked this way.

Cheers!


#4

I actually had not gotten it yet, so thank you so much! Yeah, it doesn’t seem to make much sense not putting size in brackets, but such is life. Thanks again!


#5

I also have this question of why we don’t put ‘size’ as an argument.