The question that I am stuck is below. I am learning a stack. The question I have is, according to what I have learned up until now, the constructor should be as this
def __init__(self, value=None): self.top_item = Node(value) def peek(self): return self.top_item,get_value()
But below self.top_item is set to none, yet still uses method attribute of Node. This is what throws me off.
from node import Node
# Add your Stack class below: class Stack: def __init__(self): self.top_item = None def peek(self): return self.top_item.get_value()
You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility
When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!
If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer!