Receiving invalid syntax error even when using courses own solution

File “script.py”, line 11
print(“Average insurance cost: " + str(average_cost) + " dollars.”)
^
SyntaxError: invalid syntax

This has happened on many pages. The code is written correctly, is this a possible bug in the course?

When the error is at the beginning of a line, the problem could be on the line above. You might have a missing ) somewhere.

Could you post your full code?

syntax errors are thrown by python interpeter, so then its 99.99% of the time a problem with the code

1 Like

Sure! Here is the full code>

names = ["Judith", "Abel", "Tyson", "Martha", "Beverley", "David", "Anabel"]

estimated_insurance_costs = [1000.0, 2000.0, 3000.0, 4000.0, 5000.0, 6000.0, 7000.0]

actual_insurance_costs = [1100.0, 2200.0, 3300.0, 4400.0, 5500.0, 6600.0, 7700.0]

# Add your code here

for insurance_cost in actual_insurance_costs:

  total_cost += insurance_cost

average_cost = (total_cost/len(actual_insurance_costs)

print("Average insurance cost: " + str(average_cost) + " dollars.")

for i in range(len(names)):

  name = names[i]

  insurance_cost = [actual_insurance_costs[i]]

  print("The insurance cost for" + name + " is" +str(insurance_cost) + " dollars.")

like I said:

average_cost = (total_cost/len(actual_insurance_costs)

missing )

2 Likes