#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http

제목[re]List methods 질문2021-10-19 00:34
작성자
아래 내용을 보시면 append는 파라미터로 하나의 값이 들어가는 반면 extend는 iterable 객체가 들어갑니다. iterable객체는 반복 가능한 객체를 말하며 list, dict, set 등이 있습니다. 

따라서 주어진 리스트에 무언가를 추가하는 것은 같지만 append는 하나의 값만 extend는 여러 개의 값을 한
번에 추가할 수 있는 메서드로 보시면 됩니다.
(출처: https://docs.python.org/3/tutorial/datastructures.html)
list.append(x)

Add an item to the end of the list. Equivalent to a[len(a):] = [x].

list.extend(iterable)

Extend the list by appending all the items from the iterable. Equivalent to a[len(a):] = iterable.



 

댓글
이전List methods 질문2021-10-18
다음string.max 질문2021-10-18