SyntaxError: Invalid Character In Identifier
When executing with Python it shows error: return (x * (1.0 — x)) ^ SyntaxError: invalid character in identifier How do I correct it?
Solution 1:
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!
>>> bad_minus = "—"
>>> good_minus = "-"
>>> bad_minus == good_minus
False
>>> ord(good_minus)
45
>>> ord(bad_minus)
8212
>>>
Solution 2:
Assuming the character between 1.0
and x
is supposed to be a minus sign, replace it with an actual minus sign.
Solution 3:
Your minus is not a minus. It's a "em dash".
Try replacing this '—'
with '-'
.
Post a Comment for "SyntaxError: Invalid Character In Identifier"