In lesson 3.5, I get a syntax error when trying to reassign the bmi
variable back to its original value of 26.2
.
File “script.py”, line 24
bmi = 26.2
^
SyntaxError: invalid syntax
Thank you in advance!
In lesson 3.5, I get a syntax error when trying to reassign the bmi
variable back to its original value of 26.2
.
File “script.py”, line 24
bmi = 26.2
^
SyntaxError: invalid syntax
Thank you in advance!
Lesson is here:
Hi there, and welcome to the forums!
It would be great if you could post your full code so we can see the context in which it sits, this can help with debugging the issue.
age = 28
sex = 0
bmi = 26.2
num_of_children = 3
smoker = 0
insurance_cost = 250 * age - 128 * sex + 370 * bmi + 425 * num_of_children + 24000 * smoker - 12500
print(“This person’s insurance cost is " + str(insurance_cost) + " dollars.”)
age += 4
new_insurance_cost = 250 * age - 128 * sex + 370 * bmi + 425 * num_of_children + 24000 * smoker - 12500
change_in_insurance_cost = new_insurance_cost - insurance_cost
print(“People who are four years older have estimated insurance costs that are " + str(change_in_insurance_cost) + " dollars different.”)
age = 28
bmi += 3.1
new_insurance_cost = 250 * age - 128 * sex + 370 * bmi + 425 * num_of_children + 24000 * smoker - 12500
change_in_insurance_cost = new_insurance_cost - insurance_cost
print(“The change in estimated insurance cost after increasing BMI by 3.1 is " + str(change_in_insurance_cost) + " dollars.”
bmi = 26.2
sex = 1
new_insurance_cost = 250 * age - 128 * sex + 370 * bmi + 425 * num_of_children + 24000 * smoker - 12500
change_in_insurance_cost = new_insurance_cost - insurance_cost
print(“The change in estimated insurance cost after increasing BMI by 3.1 is " + str(change_in_insurance_cost) + " dollars.”
print("The change in estimated insurance cost after increasing BMI by 3.1 is " + str(change_in_insurance_cost) + " dollars."
Note the missing close parenthesis on that print
function?
Quite often, when you get a syntax error on one line, and you can’t see anything wrong with that line, check the line before it for things like missing parentheses or quotation marks.
That worked. Thank you!