Brynne Reynolds Brynne Reynolds - 6 months ago 24
Python Question

I don't know what the output code is. The compiler says there is an invalid character in identifier of line 3

b = 0
for a in range(0, 10, 2):
b += a − 1
print(a," ",b)


I am practicing on a past paper. Please help. And can someone please explain
the break and continue functions.

Answer

Character is not a correct python identifier for minus operator, you need - instead:

>>> 3 − 1
  File "<stdin>", line 1
    3 − 1
      ^
SyntaxError: invalid character in identifier
>>> 
>>> 3 - 1
2

It's actually a unicode with code point 8722:

>>> ord('−')
8722