ModdersCentral

Full Version: Python Stack
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
#
#4/7/2018
#name

print("******************************")
print(" ")
print("******************************")
print("\n\n")

class Stack: 
    def __init__(self):
        self.stack = list() 
    def push(self,data): 
        if data not in self.stack:
            self.stack.append(data)
            return True
        return False 
    def pop(self):
        return self.stack.pop() 
    def size(self):
        return len(self.stack)

myStack = Stack()
myStack.push(5)
print(myStack.pop())   #prints 5
www.000webhost.com