[파이썬/python] 백준 10828번 : 스택(🥈4)

import sys
input = sys.stdin.readline

x = []

for i in range(int(input())):
    n = list(map(str,input().split()))
    if n[0] == 'push':
        x.append(int(n[1]))
    elif n[0] == 'top':
        print(x[-1] if len(x) != 0 else -1)
    elif n[0] == 'empty':
        print(1 if len(x) == 0 else 0)
    elif n[0] == 'size':
        print(len(x))
    else:
        print(-1 if len(x) == 0 else x.pop())

list(map(str,input().split())) 로 안 하고 그냥 input().split()을 했어도 됐을 것 같다

comment