Syntaxerror invalid character in identifier

скрипт лежит в директории питона

Давай подробно рассказывай, как запускаешь все (где лежит, как запускаешь и т д)? Скрины приложи.

если скрипт не класть в директорию питона он и вовсе не запускается(

Want to improve this question? Update the question so it’s on-topic for Stack Overflow.

Closed 2 years ago .

When executing with Python it shows error:

How do I correct it?

3 Answers 3

Use the correct character for you minus operator: — . You are using some other ‘dash’ character that the interpreter is considering just a name like y or x . But it is invalid!

Assuming the character between 1.0 and x is supposed to be a minus sign, replace it with an actual minus sign.

Your minus is not a minus. It’s a "em dash". Try replacing this ‘—’ with ‘-‘ .

Not the answer you’re looking for? Browse other questions tagged python python-3.x or ask your own question.

Linked

Related

Hot Network Questions

site design / logo © 2020 Stack Exchange Inc; user contributions licensed under cc by-sa 4.0 with attribution required. rev 2020.1.17.35809

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

6 Answers 6

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.

Читайте также:  Intel h110 чипсет драйвер

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.

Rate this post

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *