def solution(lottos, win_nums):
z, w = 0, 0
for l in lottos:
if l in win_nums:
w += 1
elif l==0:
z += 1
answer = [6 if 7-(z+w)==7 else 7-(z+w), 6 if (7-w)==7 else 7-w]
return answer
순위와 당첨 숫자 개수의 합이 7인 점을 이용해 계산
+ 다른 풀이
def solution(lottos, win_nums):
rank = [6, 6, 5, 4, 3, 2, 1]
w = len([i for i in lottos if i in win_nums])
z = lottos.count(0)
answer = [rank[w+z], rank[w]]
return answer
for문 없이 각 변수를 한 줄로 count하고 당첨 숫자 개수를 인덱스로 하는 rank 배열을 선언