Error message on Python for Data Science: Fundamentals --> List and For loops

Hi there,
I am having issues in the ‘List and For loops’ aspect. I execute the instructions given but the program keeps bringing ‘SyntaxError: invalid character in identifier’.

Please can you guide me on what to do? The subsequent topics are also bringing the same error message even after typing the answer word for word!

Thanks.

Hi there,

From googling the error:

I found the following description:

The error SyntaxError: invalid character in identifier means you have some character in the middle of a variable name, function, etc. that’s not a letter, number, or underscore.

Visually, it’s difficult to see exactly where this is happening in your code, but the answer provides a way that you can try and work out what’s happening.

Alternatively, you might find by deleting the line in question (the error message indicates it the rating = row[-1] line) and retyping it you might solve the issue.

Lastly, if you copy paste the code text into a reply here, it’s possible whatever the invalid character is will paste cleanly, and myself or someone else might be able to help diagnose.

I hope this is able to move you towards solving the problem, let me know how you go!

Hi aisraj12000,
How were you able to solve this problem, I am having the same problem right now. I will really appreciate your urgent response.!

https://app.dataquest.io/m/312/lists-and-for-loops/9/for-loops

Screenshot_20200617-174301|250x500

@sadorwilliamz3 I would suggest asking a new, separate question because as per the image you shared, the error you get is not the same as the question posted here originally. It’s better to ask a separate question, and in the format recommended by Dataquest as well.

Hi aisraj12000,
I just got the same problem like this just now, pls guide me on how you were able to solve your own thanks.

Hi Williams,

I am still unable to resolve the issue. All I do is that I check my code with the answer and ensure they correspond.

1 Like

Hi @aisraj12000,

Sorry about that. I would recommend you to to go through the rest of the mission and let us know via the Contact Us link above. We will mark that mission as complete.

Best,
Sahil

@aisraj12000, I have gotten a solution to the error. This was how I did it below:

  1. Note that the syntax error message indicates this symbol ^ at line 10 (rating = [-1])
  2. Place your text cursor at the back r
  3. Press space bar once and run(not submit) the code
  4. You will notice another syntax error at line 10 or 11 or 12
  5. If it is line 10, repeat step 2 and 3 above
  6. If the error occour at line 10 again repeat the process one more time
  7. You will notice that the syntax error will no longer indicates line 10 but now line 11
  8. Do the same process in step 2 and 3 above to line 11 until the error indicates line 12
  9. Do the same thing to line 12, then your code will run successfully.

I hope this solve your problem too just like mine