Stack using Linked List (py)

Run Settings
LanguagePython
Language Version
Run Command
class Node: def __init__(self,data): self.data = data self.next = None def setTop(self,data): self.Top = data class Stack: def __init__(self, top=None): self.top = top self.bottom = None self.length = 0 def peek(self): x = self.top if x != None: print(x.data) else: print('None') def push(self,data): node = Node(data) node.next = self.top self.top = node self.length+=1 def pop(self): curr = self.top self.top = curr.next self.length-=1 def isEmpty(self): if self.top == None: print('True') else: print('False') if __name__ == '__main__': stack = Stack() stack.push('Google') stack.push(10) stack.push('Udemy') stack.push(50) stack.pop() stack.pop() stack.pop() stack.pop() stack.peek() stack.isEmpty()
Editor Settings
Theme
Key bindings
Full width
Lines