23.3.24 TIL

HS L·2023년 3월 24일
0

내일배움캠프

목록 보기
12/73

초보자를 위한 파이썬 300제

1~100번 진행

list 중복없이 합치기

a_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
b_list = [7, 8, 9, 10, 11, 12, 13, 14, 15]

리스트 중복없이 합치기1
for b in b_list:
    if b in a_list:
        pass
    else:
        a_list.append(b)
print(a_list)

# 리스트 중복없이 합치기2
list = set(a_list) | set(b_list)
print(list)
profile
식이

0개의 댓글