from node import Node class Stack: def __init__(self, value = None): self.top_item = Node(value) class Stack: def __init__(self): self.top_item = None
I am a beginner and learning stack for the first time. Above the two constructor seems to do the same thing. But I don’t quite get it. what does it mean when you set a node to None? and self.top_item is not even an instance of class Node. why does it act like one?
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!