TIL 221024 Stack (in python)

sohyun_·2022년 10월 24일
0

파이썬에서 스택 사용하기

🧡스택??
가장 나중에 들어온 자료가 가장 먼저 처리되는 LIFO 방식의 자료구조

python에서 stack 구현하기

❤ init

#빈 스택으로 초기화 하는 방법
stack=[]

❤ push

#스택에 원소 넣기
stack=[1,2,3]
stack.append(4)

=>[1,2,3,4]

❤ pop

#스택에 가장 마지막 원소 제거하기
stack=[1,2,3]
stack.pop()

=> [1,2]

🔗참고
https://ooeunz.tistory.com/7

profile
web backend developer

0개의 댓글