<오답>
def solution(price, money, count):
answer = 0
for i in range(1,count+1):
answer += price*i
return answer - money
<정답>
def solution(price, money, count):
answer = 0
for i in range(1,count+1):
answer += price*i
if answer < money:
return 0
else:
return answer - money
'문제풀이 > 프로그래머스' 카테고리의 다른 글
[프로그래머스][Lv2] - 더 맵게 (Python) (0) | 2021.10.15 |
---|---|
[프로그래머스][Lv1] - [1차] 비밀지도 (Python) (0) | 2021.10.15 |
[프로그래머스][Lv1] - k번째 수 (Python) (0) | 2021.10.14 |
[프로그래머스][Lv1] - 숫자 문자열과 영단어(Python) (0) | 2021.10.14 |
[프로그래머스][Lv1] - 로또의 최고 순위와 최저 순위(Python) (0) | 2021.10.12 |