Can you use the += and add multiple variables (example - print(“The total price is”, new_sneakers += nice_sweater += fun_books)
Hello, @raydude6131, and welcome to the Codecademy Forums!
+= is an assignment operator, and cannot be used within a call to the
However, you can use the
+= operator to add the value of an expression containing multiple variables to the value of the variable to the left of that assignment operator.
Edited on January 1, 2020 to add this example:
Following is an example:
a += b + 3 * c + d
That adds the value of
b + 3 * c + d to the value of
a and saves the result to
Edited on January 2, 2020 to add the following:
In the case of keyword arguments, the
= operator can be included as part of a function call. See
Here is an example:
print("Hello", "World", sep=", ", end="!")