+ 1
super sale code coach
import math numbers = input() numbers_list = list(map(int, numbers.split(","))) highest = max(numbers_list) remaining = [num for num in numbers_list if num != highest] sum_remaining = sum(remaining) tax = sum_remaining*0.07 discount = sum(remaining)*0.3 discounted_items = sum_remaining-discount new_price =discounted_items+highest+tax savings = sum(numbers_list) - new_price print(round(savings)) This is my code for the super sale quizz. But I only get 4 right of 7. Can anyone help me. It's in Python
1 Resposta
+ 1
Joakim Lindstrom ,
a quite nice code, but some issues should be fixed:
> input numbers should be mapped to float, not to int
numbers_list = list(map(float, numbers.split(",")))
> the second part of the code where the discount will be calculated looks a bit too complicated - see my sample.
> do not use any rounding, just convert the final discount to int.
> calculating the tax should use 1.07 not 0.07
# your code:
numbers = input()
numbers_list = list(map(float, numbers.split(",")))
highest = max(numbers_list)
remaining = [num for num in numbers_list if num != highest]
sum_remaining = sum(remaining)
# new:
discount = sum_remaining * 0.3 * 1.07
print(int(discount))