728x90
[나의 코드]
def solution(num_list, n):
answer = []
num = len(num_list)
a = num//n
i=0
while True:
answer.append(num_list[i:i+n])
if i+n==num:
return answer
else:
pass
i += n
return answer
[다른 사람 코드]
def solution(num_list, n):
answer = []
for i in range(0, len(num_list), n):
answer.append(num_list[i:i+n])
return answer
728x90
'STUDY > Python' 카테고리의 다른 글
[프로그래머스] 음양 더하기 파이썬 (0) | 2023.04.06 |
---|---|
[프로그래머스] K의 개수 파이썬 (0) | 2023.04.06 |
[deque] 양방향 자료형 - 파이썬 (0) | 2023.04.04 |
python 숫자 판별 함수 isdigit (0) | 2023.04.03 |
파이썬 두 개 리스트 간 중복 요소 (0) | 2023.04.03 |