def discount(size, count): price_8oz = 1.20 price_12oz = 1.75 price_12oz_discount = 1.35 if size == 8: return price_8oz * count elif size == 12: if count <= 4: return price_12oz * count elif count > 4: # divmod() divides one number by another and returns both the number of times # the second number fits into the first, but also the remainder. # Here we calculate how many times five goes into the customer order # and how many extra cups are left over. fivecount, remainder = divmod(count, 5) return price_12oz_discount * fivecount * 5 + 1.75 * remainder # Here we test the code to make sure that it works across several iterations of five counts # with 12 ounce cups. for count in range(2, 12): print('count:', count, 'cost:', discount(12, count))