The following is the code for the Receipts for lovely loveseats. It’s not adding sales tax to the total and I’m unsure what to do. Do I update the variable?
lovely_loveseat_description = “”"
Lovely Loveseat. Tufted polyester blend on wood. 32 inches high x 40 inches wide x 30 inches deep. Red or white.
“”"
lovely_loveseat_price = 254.00
stylish_settee_description = “”"
Stylish Settee. Faux leather on birch. 29.50 inches high x 54.75 inches wide x 28 inches deep. Black.
“”"
stylish_settee_price = 180.50
luxurious_lamp_description = “”"
Luxurious Lamp. Glass and iron. 36 inches tall. Brown with cream shade.
You have to update the customer_one_total variable each time an item is added. Then create a variable, customer_one_tax which is equal to the customer_one_total * sales tax.
It’s okay, let’s break it down. += works like this:
a = 3
b = 5
a += b
print(a)
>>>Which prints out 8
So, the right side (operand) is added to the variable on the left side, or, the left operand (if you want to use the appropriate lexicon).
Currently, you have a variable called customer_one_total = 0. Every time that person buys something (represented on the right, it gets added to the left side via the assignment operator, +=
So, in your code you also created a variable called ‘customer_one_tax’:
So now you have two variables, the total AND the tax and you need to update the customer_one_total variable which is accomplished by using the += operator.
I understand the += but I also see that the value of customer_one_total is 0 and that the customer_one_tax isn’t multiplying anything but zero. I’m unsure where to place the update.
customer_one_total starts out as 0. But items are added to the variable.
These two pieces are incorrect. You’re asked to add one item at a time according to the steps.
If you add print() statements after each step you can see what your code is doing. ie:
You’re calculating the tax before you’ve added anything to the total. The way you have the code written, the value of the customer_one_total variable is 0. So, your end result is 0. (I’m also just following exactly what the steps in the lesson ask me to do.) Adding each item to the total.