250204 학습()

송용진·약 3시간 전
0

깊은 복사

import copy

priorities = [[1, 2], [3, 4]]
deep_copy = copy.deepcopy(priorities)  # 깊은 복사

deep_copy[0][0] = 10  # 복사한 리스트 수정
print(priorities)  # [[1, 2], [3, 4]] - 원본은 그대로
print(deep_copy)  # [[10, 2], [3, 4]] - 복사본만 수정됨

filter 함수

# filter 함수를 사용하여 짝수만 남김 (람다 함수 사용)
even_numbers = list(filter(lambda n: n % 2 == 0, numbers))

print(even_numbers)  # [2, 4, 6, 8, 10]
profile
백엔드 개발자

0개의 댓글