Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python syntax error: can't assign to operator in module but works in interpreter

Tags:

python

syntax

I have a string a and I would like to split it in half depending on its length, so I have

a-front = len(a) / 2 + len(a) % 2

this works fine in the interpreter but when i run the module from the command line python gives me a SyntaxError: can't assign to operator. What could be the issue here.

like image 534
mzee Avatar asked Apr 23 '10 09:04

mzee


1 Answers

You might mistype hyphen and underscore, try

a_front = len(a) / 2 + len(a) % 2
like image 188
YOU Avatar answered Oct 04 '22 07:10

YOU