## 문제

스택 구현하기


## CODE

import sys
input = lambda : sys.stdin.readline().rstrip()
def stackdef(n,usestack):
stack = usestack
if n[0] == 'push':
stack += [int(n[1])]
elif n[0] == 'pop':
if len(stack) == 0:
print(-1)
else:
print(stack[-1])
stack = stack[:-1]
elif n[0] == 'size':
print(len(stack))
elif n[0] == 'empty':
if len(stack) == 0:
print(1)
else: print(0)
elif n[0] == 'top':
if len(stack) == 0:
print(-1)
else: print(stack[-1])
else:
print(stack)
return stack
stack = []
for k in range(int(input())):
n = input().split()
stack = stackdef(n,stack)
view raw 10828.py hosted with ❤ by GitHub


sys.stdin.readline() 을 사용할때 매번 개행문자와 EOF을 지우는 과정을 거쳤었는데

```python

import sys
input = lambda : sys.stdin.readline().rstrip()

```

이거면 깔끔하게 된다.