Receipts for Lovely Loveseats

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.

“”"

luxurious_lamp_price = 52.15

sales_tax = .088

customer_one_total = 0

customer_one_itemization = “”

customer_one_tax = customer_one_total * sales_tax

customer_one_total += lovely_loveseat_price + luxurious_lamp_price + customer_one_tax

customer_one_itemization += lovely_loveseat_description + luxurious_lamp_description

print(“Customer One Items:”)

print(customer_one_itemization)

print(“Customer One Total:”)

print(customer_one_total)

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.

How do I go about doing that?

You’re updating the customer_one_total += __the item that's purchased goes here__

(It also helps to use print() statements to see a running total of what the person is buying)

Maybe visualize it like using a calculator; you’re adding items together.

Then you’re asked to create a variable called customer_one_tax which is equal to the customer_one_total * sales_tax variable.

Then, you have to update the customer_one_total variable using += what? ___

Revisit how you’re calculating this part here:

customer_one_total += lovely_loveseat_price + luxurious_lamp_price + customer_one_tax

It might help to look up how the assignment operator += works too.

1 Like

Sorry, I’m not sure.

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’:

customer_one_tax = customer_one_total * sales_tax
print(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.

Which is…

customer_one_total += customer_one_tax

Does that make sense?

On Assignment operators:
https://www.geeksforgeeks.org/assignment-operators-in-python/

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:

#8
customer_one_total = 0
#9
customer_one_itemization = lovely_loveseat_description

#10
customer_one_total +=  lovely_loveseat_price
print(customer_one_total)

customer_one_total += luxurious_lamp_price
print(customer_one_total)

etc.

1 Like

Ah ok, thank you. I thought you could update customer_one_total in one command but you have to do it for each item. Is that the most efficient way?

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.

1 Like

Thank you very much for the explanation and the help.

1 Like

lovely_loveseat_description = “Lovely Loveseat. Tufted polyester blend on wood. 32 inches high x 40 inches wide x 30 inches deep. Red or white”

Love seat Price

lovely_loveseat_price = 254.00

Expaning items

stylish_settee_description = “Stylish Settee. Faux leather on birch. 29.50 inches high x 54.75 inches wide x 28 inches deep. Black.”

Sette Price

stylish_settee_price = 180.50

Expanding Inventory

luxurious_lamp_description = “Luxurious Lamp. Glass and iron. 36 inches tall. Brown with cream shade”

Luxurious Lamp Price

luxurious_lamp_price = 52.15

Sales Tax

sales_tax = .008

First Customer enters

customer_one_total = 0

customer_one_total += lovely_loveseat_price + luxurious_lamp_price

Items customer one is buying

customer_one_itemization = “”

customer_one_itemization += lovely_loveseat_description + luxurious_lamp_description

#customer one checkout

customer_one_tax = customer_one_total * sales_tax

Customer One Receipt.

this is my code thus far but for some reason for the customer_one_tax it keeps telling me it is undefined, not sure what to do ?

Please don’t revive old threads from 2 years ago.

follow these guidelines: