Python Syntax: Medical Insurance Project - SyntaxError Message

Hello!

I’ve just started the Python Syntax: Medical Insurance Project and I’m getting a syntax error when I add the following code:

insurance_cost = 250 * age - 128 * sex + 370 * bmi + 425 * num_of_children + 24000 * smoker - 12500

The link to the exercise is here:
https://www.codecademy.com/paths/data-analyst/tracks/dacp-python-fundamentals/modules/dscp-python-syntax/projects/ds-python-syntax-project

The error message is: SyntaxError: can’t use starred expression here

I’m not sure where the error is. Has anyone else had this issue?

Thanks for your help!

Tabby :slightly_smiling_face:

Can you please post all of your formatted code?
Sometimes the error is above the line that’s specified in the error message.

Thanks, yes!

This is the all of the formatted code:

create the initial variables below

age = 28

sex = 0

bmi = 26.2

num_of_children = 3

smoker = 0

Add insurance estimate formula below

insurance_cost = 250 * age - 128 * sex + 370

  • bmi + 425 * num_of_children + 24000

  • smoker - 12500

Actually the formatting was off. It’s:

create the initial variables below

age = 28

sex = 0

bmi = 26.2

num_of_children = 3

smoker = 0

Add insurance estimate formula below

insurance_cost = 250 * age - 128 * sex + 370

  • bmi + 425 * num_of_children + 24000

  • smoker - 12500

Sometimes this happens when one copies the code and pastes it into the script.py window in the learning environment. Did you try to type out the asterisk (and the formula) rather than pasting it?

Here’s the post about formatting code:
https://discuss.codecademy.com/t/how-to-format-code-in-posts/51139/7a

1 Like

Thanks so much! I’ll try that.

same message : /

Did you try resetting that window and then maybe try putting 370 on the next line so that line doesn’t begin with the “*”

like:

1 Like

I’ll try. Thank you!

1 Like

That worked. Thank you so much!

1 Like

Whew! Good!
Sometimes it’s the smallest things. :slightly_smiling_face:

Right! Thanks again for your help! :slightly_smiling_face:

1 Like