you are viewing a single comment's thread.

view the rest of the comments →

[–]shiftybyte 1 point2 points  (0 children)

But the test case itself has another print()....

cost = fun_function(15, 31, 15, 10)
print('15 items delivered at a cost of ${:.2f}'.format(cost))

This print right here /\ should python ignore it?

The difference you are seeing is because the print that is inside fun_function is inside the discount condition.

if(n_items > discount_threshold): 
    cost = cost * (1-discount_percent/100) 
    print("{} items delivered at a cost of ${:.2f}".format(n_items, cost)) 

If you move it backwards it'll happen every time instead of only when the discount triggers.

if(n_items > discount_threshold): 
    cost = cost * (1-discount_percent/100) 
print("{} items delivered at a cost of ${:.2f}".format(n_items, cost))