[Python] *(Asterisk)의 Unpacking 역할

Melon Coder·2023년 2월 14일

Python

목록 보기
1/4
post-thumbnail

백준으로 알고리즘 공부를 하던 중 리스트 안에 있는 요소들을 괄호없이 출력해야 하는 일이 생겨서 찾아보다가 리스트 앞에 '*(Asterisk)'를 붙이면 unpacking이 된다는 걸 알게 되었다.

예를 들어,

>>> num_list = [1,2,3,4,5]

>>> print(num_list)
[1, 2, 3, 4, 5]

>>> print(*num_list)
1 2 3 4 5
profile
create new things

0개의 댓글