프로그래머스 옷가게 할인 받기 13,14 case 오류 파이썬

2023. 2. 24. 16:27_Study/Baekjoon

728x90

소수점을 버려줘야 한다

 

 

#디버그용 소스코드

def solution(price):
    if (price >= 500000):
        answer = price*0.8
    elif (price >= 300000):
         answer = price*0.90
    elif (price >= 100000):
        answer = price*0.95
    else: answer = price
    print(answer)
    return answer

array = [i for i in range(10,1000000)]
#n = list(map(str,input().split(',')))
for i in range(len(array)):
    solution(array[i])

 

#정답코드

def solution(price):
    if (price >= 500000):
        answer = price*0.8
    elif (price >= 300000):
         answer = price*0.90
    elif (price >= 100000):
        answer = price*0.95
    else: answer = price
    return int(answer)