데이터 구조 #2
스택(stack)의 리스트 >>> stack = [1, 2, 3] >>> stack.append(4) >>> stack.append(5) >>> stack [1, 2, 3, 4, 5] >>> stack.pop() 5 >>> stack [1, 2, 3, 4] >>> stack.pop() 4 >>> stack.pop() 3 >>> stack [1, 2]--------------------------------------------------------------------------큐(queue)리스트>>> from collections import deque #popleft를 사용하기 위해추가 >>> queue = deque(["김", "이", "최"]) >>> queue.append("강") # Terr..
더보기
데이터 구조 #1
list.append(x) :리스트끝에 x값을 추가 list.extend(L) :리스트 전체를 추가 ex) a = [1, 2 , 3] b = [10, 20 , 30] a.expend(b) a [1, 2, 3, 10, 20 , 30] list.insert(i,x) :i자리에 x값을 추가 list.remove(x) :x값을 제거(값을 넣어줘야됨) lilst.pop() :list값의 마지막 자리를 제거 list. index(x) :x의 자리 위치를 알려줌 list.count(x) :x값을 겟수를 알려줌 list.sort() : 크기순서대로 정렬 list.reverse() :값을 거꾸로 돌려줌
더보기