f = open('./words.txt')
. Точка со слешом указывает на текущую директорию.class Stack:
def __init__(self):
self.stack = []
def push(self, item):
self.stack.append(item)
def pop(self):
self.stack.pop()
def get(self):
return self.stack
def get_even(self):
return [item for item in self.stack if item % 2 == 0]
def get_uneven(self):
return [item for item in self.stack if item % 2 != 0]
if __name__ == '__main__':
stack = Stack()
stack.push(1)
stack.push(2)
stack.push(3)
stack.push(4)
print(stack.get_even())
print(stack.get_uneven())
class Stack:
def __init__(self):
self.stack = []
def push(self, item):
self.stack.append(item)
def pop(self):
self.stack.pop()
def get(self):
return self.stack
if __name__ == '__main__':
stack = Stack()
stack.push(1)
stack.push(2)
stack.push(3)
print(stack.get())
stack.pop()
print(stack.get())