Я работаю над проблемой распространения письма из войн HP code 2012. Я продолжаю получать сообщение об ошибке, которое говорит о недопустимом символе в идентификаторе. Что это значит и как оно может быть исправлено. вот страница с информацией. hpcodewars.org/past/cw15/problems/2012ProblemsFinalForPrinting.pdf вот код
Ошибка SyntaxError: invalid character in identifier означает, что у вас есть символ в середине имени переменной, функции и т.д., а не буквы, цифры или подчеркивания. Фактическое сообщение об ошибке будет выглядеть примерно так:
Это говорит вам, что представляет собой настоящая проблема, поэтому вам не нужно угадать, «где у меня есть недопустимый символ»? Ну, если вы посмотрите на эту строку, у вас есть куча непечатаемых символов мусора. Выньте их, и вы преодолеете это.
Если вы хотите знать, каковы фактические символы мусора, я скопировал строку нарушения из вашего кода и вставил ее в строку в интерпретаторе Python:
Итак, это u200b , или ZERO WIDTH SPACE. Это объясняет, почему вы не видите его на странице. Как правило, вы получаете их, потому что вы скопировали некоторый отформатированный (не обычный текст) код с сайта, такого как StackOverflow или wiki, или из файла PDF.
Если ваш редактор не дает вам способ найти и исправить эти символы, просто удалите и повторно введите строку.
Конечно, у вас также есть как минимум два IndentationError из не отступающих вещей, по крайней мере еще один SyntaxError из пробелов (например, = = вместо == ) или подчеркивания, превращенные в пробелы (например, analysis results вместо analysis_results ).
Вопрос в том, как вы получили свой код в этом состоянии? Если вы используете что-то вроде Microsoft Word в качестве редактора кода, это ваша проблема. Используйте текстовый редактор. Если нет. ну, какова бы ни была проблема с корнем, которая заставила вас в конечном итоге с этими мусорными символами, сломанным отступом и дополнительными пробелами, исправить это, прежде чем пытаться исправить свой код.
I am working on the letter distribution problem from HP code wars 2012. I keep getting an error message that says invalid character in identifier. What does this mean and how can it be fixed. here is the page with the information. hpcodewars.org/past/cw15/problems/2012ProblemsFinalForPrinting.pdf here is the code

5 Answers 5
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. The actual error message will look something like this:
That tells you what the actual problem is, so you don’t have to guess «where do I have an invalid character»? Well, if you look at that line, you’ve got a bunch of non-printing garbage characters in there. Take them out, and you’ll get past this.
If you want to know what the actual garbage characters are, I copied the offending line from your code and pasted it into a string in a Python interpreter:
So, that’s u200b , or ZERO WIDTH SPACE. That explains why you can’t see it on the page. Most commonly, you get these because you’ve copied some formatted (not plain-text) code off a site like StackOverflow or a wiki, or out of a PDF file.
If your editor doesn’t give you a way to find and fix those characters, just delete and retype the line.
Of course you’ve also got at least two IndentationError s from not indenting things, at least one more SyntaxError from stay spaces (like = = instead of == ) or underscores turned into spaces (like analysis results instead of analysis_results ).
The question is, how did you get your code into this state? If you’re using something like Microsoft Word as a code editor, that’s your problem. Use a text editor. If not… well, whatever the root problem is that caused you to end up with these garbage characters, broken indentation, and extra spaces, fix that, before you try to fix your code.
a igqwG d Zqj cx b z y wk NkKfg H Sco o uu n TFiH e aYC y csKeK p iAkui o vUl t laES
Answer Wiki
![]()
Identifiers or “names” can have only the following characters in python
a to z (alphabets lowercase)
A to Z (alphabets uppercase)
That’s it, only this much is legal. Check if you have any other characters in the variable, classes or function names in your code.
You can get away with a . (Period) as a part of an identifier and not hit that runtime error. That’s because when you use period python thinks you are trying to access functions and variables in a module or class.