python - <__main__.Stack instance at 0x021ED328> -


i'm doing exercise interactivepython.org. whenever run code shows me error "<__main__.stack instance @ 0x021ed328>":

class stack:      def __init__(self):         self.items = []      def isempty(self):         return self.items == []      def push(self, item):         self.items.insert(0,item)      def pop(self):         return self.items.pop(0)      def peek(self):         return self.items[0]      def size(self):         return len(self.items) m = stack() m.push('x') m.push('y') m.push('z') print m 

you printed m , m instance of class stack. output right.

if want print items, u should

print m.items 

or can write method __str__ in stack class print u want


Comments