SyntaxError: Want to resolve invalid character identifier [overlapping]

Asked 2 years ago, Updated 2 years ago, 344 views

(Two answers) 10 months ago

I'm sure this syntax is correct, but I get a SyntaxError: invalid character identifier error similar to the title in else:.

Could you please let me know where the mistake is?

for i in range(v):
    if i%2 == 0:
       print("i=",i)
   else:
       print("")

python

2022-09-30 22:00

2 Answers

The else line contains full-width blank characters.

Example of blank characters displayed in the editor:

Enter a description of the image here


2022-09-30 22:00

That's a common mistake.

 else:

The first character in this line is a full-width blank.
You can correct it to two half-width spaces.

By the way, if you type an error message in the search field at the top of this site, you will find a similar article like the one below, so please try it from now on.

What is the cause of the error SyntaxError: invalid character in identifier
SyntaxError: I want to resolve invalid character identifier
I don't know how to improve the error code. SyntaxError: invalid character in identifier


2022-09-30 22:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.