Python Forum

Full Version: SyntaxError: invalid character in identifier
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
complete newbie here. Was practicing on pycharm and can't figure out why I'm getting such a rudimentary error. Please see below. Any feedback would be greatly appreciated. Thank you in advance.

add = ​3 ​+ ​2
sub = ​5 ​- ​4
mult = ​5 ​* ​2
div = ​7 ​/ ​2
power = ​4 ​** ​2
mod = ​7 ​% ​5
print (add, sub, mult, div, power, mod)



below is what happens when I run the code:

add = ​3 ​+ ​2
^
SyntaxError: invalid character in identifier

Process finished with exit code 1
You manged some how to get \u200 zero width space Unicode character in all calculation.
>>> s = 'add = ​3 ​+ ​2'
>>> repr(s)
"'add = \\u200b3 \\u200b+ \\u200b2'"
Copy code under and run,then should be okay.
add = 3 + 2
sub = 5 - 4
mult = 5 * 2
div = 7 / 2
power = 4 ** 2
mod = 7 % 5
print(add, sub, mult, div, power, mod)
Output:
5 1 10 3.5 16 2
thank you so very much! I's working fine now
I'm unclear though on what I did to cause the error and is there a way to correct the \u200 width space issue permanently as you pointed out?
thanks again!
really appreciate it