I was working on the Python Dictionaries project when I came across the following error:
File "script.py", line 35
medical_records["Valentina"] = {"Age": 52, "Sex": "Female", "BMI": 18.7, "Children": 01, "Smoker": "Non-smoker", "Insurance_cost": 6420.0}
^
SyntaxError: invalid token
I went to that line, and noticed I forgotten a “,” so I corrected that but the error persisted. The only other thing out of place was I accidentally did 01 for children instead of 1. I changed it, not thinking that was the error, but that fixed the problem! Huzzah! However, I have no idea why that provoked the SyntaxError. Is 01 not an acceptable integer? I looked around the forums and the closest I got was an answer by mtk, but it was related to DateTime and it didn’t shed any light on why it doesn’t work with 01, but works with 1.
Thank you!