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

落花浮王杯 提交于 2020-01-14 07:34:07

问题


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.


回答1:


You might mistype hyphen and underscore, try

a_front = len(a) / 2 + len(a) % 2


来源:https://stackoverflow.com/questions/2697610/python-syntax-error-cant-assign-to-operator-in-module-but-works-in-interpreter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!