파이썬 list 메소드에서 append()와 extend()의 차이점:
def solution():
    x = [1, 2, 3]
    x.append([4, 5])    #[1, 2, 3, [4, 5]]
    y = [1, 2, 3]
    y.extend([4, 5])    #[1, 2, 3, 4, 5]
if __name__ == '__main__':
    solution()
append(): object를 맨 뒤에 추가합니다.
extend(): iterable 객체(리스트, 튜플, 딕셔너리 등)의 엘레멘트를 list에 appending시킵니다.
'Language > python' 카테고리의 다른 글
| python - 내장함수 (0) | 2019.12.22 | 
|---|---|
| python - set :집합 (0) | 2019.12.21 | 
| python - List (1) | 2019.12.21 | 
| python - map,filter,reduce: 조건 변형 (0) | 2019.12.09 | 
| python - combinations,permutations:순열과 조합 (0) | 2019.12.08 | 
