[프로그래머스] 로또의 최고 순위와 최저 순위
count 함수 활용!
파이썬
def solution(lottos, win_nums):
answer = [0,0]
rank = [6,6,5,4,3,2,1]
cnt = 0
cnt1 = lottos.count(0)
for i in lottos:
if i in win_nums:
cnt+=1
answer[0],answer[1] = rank[cnt+cnt1], rank[cnt]
return answer
댓글남기기