CodingTest/[프로그래머스 LV.0]
프로그래머스 LV.0 - 옷가게 할인 받기[Python]
짱엉
2023. 1. 21. 23:43
728x90
나의 코드
def solution(price):
if price >= 500000:
return int(price*0.8)
elif price >= 300000 and price < 500000:
return int(price * 0.9)
elif price >= 100000 and price < 300000:
return int(price * 0.95)
else:
return int(price)
.
.
def solution(price):
discount_rates = {500000: 0.8, 300000: 0.9, 100000: 0.95, 0: 1}
for discount_price, discount_rate in discount_rates.items():
if price >= discount_price:
return int(price * discount_rate)
다른 분의 코드
깔끔 그 자체인 코드..
728x90