# 왼쪽에 요소값 추가하기 (1) - appendleft
import collections
lst = ['a','b','c','d','e','f','g']
deq = collections.deque(lst)
deq.appendleft('h')
print(list(deq))
['h', 'a', 'b', 'c', 'd', 'e', 'f', 'g']
# 왼쪽에 요소값 추가하기 (2) - extendleft
import collections
lst = ['a','b','c','d','e','f','g']
deq = collections.deque(lst)
deq.extendleft('h')
print(list(deq))
['h', 'a', 'b', 'c', 'd', 'e', 'f', 'g']
'Python > Data Struc & algo' 카테고리의 다른 글
[Python] IIS log date Sqlite3 Memory DB and pandas DataFrame (0) | 2018.05.24 |
---|---|
[Python] collections namedtuple (이름을 가진 튜플) (0) | 2018.05.19 |
[Python] collections Counter를 이용한 합집합, 교집합, 차집합 구하기 (0) | 2018.05.13 |
[Python] To find the sum of odd numbers up to the number range of N. (파이썬 N의 수 범위까지의 홀수의 합 구하기) (0) | 2018.04.22 |
[Python] 홀수의 정수 리스트에서 중간값 추출하기 (1) | 2018.04.19 |
[Python] 회문 판별(palindrome) (0) | 2018.04.18 |
프로그래머스 Lv2 - 자연수를 뒤집어 리스트로 만들기 (0) | 2018.04.18 |
프로그래머스 Lv1 - x만큼 간격이 있는 n개의 숫자 (0) | 2018.04.18 |