본문 바로가기
Algorithm

[List] append VS. extend

by YGSEO 2021. 4. 19.
728x90
s = list(range(3))
s.append(10)
print(s)

s = list(range(3))
s.append([10])
print(s)

s = list(range(3))
s.extend([10])
print(s)

output

[0, 1, 2, 10]
[0, 1, 2, [10]]
[0, 1, 2, 10]

 

728x90

댓글