Plus equals

Hello everyone, Pls can someone help me out with this.

We’re doing a little bit of online shopping and find a pair of new sneakers. Right before we check out, we spot a nice sweater and some fun books we also want to purchase!

Use the += operator to update the total_price to include the prices of nice_sweater and fun_books .

The prices (also included in the workspace) are:

  • new_sneakers = 50.00
  • nice_sweater = 39.00
  • fun_books = 20.00

https://www.codecademy.com/courses/learn-python-3/lessons/learn-python-syntax/exercises/plus-equals

Hi there.

I’ve moved your topic into the Python category, rather than General Programming. :slight_smile:

I’m guessing that you’re confused about how to use the += operator?

Basically, it’s a shortcut.

We can do this:

# create a variable with value 4:
my_number = 4
# add 5 to "my_number"
my_number = my_number + 5
# what's the new value of my_number?
print(my_number) # output: 9 

or, with the += operator:

# we have the same starting value:
my_number = 4
# but this time, we'll use the += operator to add 5 to the value
my_number += 5
# do we get the same output?
print(my_number) # output: 9

Does that make sense?

You should be able to use these examples to work out how to solve that task for the exercise. :slight_smile:

3 Likes