SyntaxError: cannot assign to operator
Make sure the variable does not have a hyphen (-).
Hyphens are not allowed in variable names in Python and are used as subtraction operators.
Example:
my-variable = 5 # would result in 'SyntaxError: can't assign to operator'
Python is upset because you are attempting to assign a value to something that can't be assigned a value.
((t[1])/length) * t[1] += string
When you use an assignment operator, you assign the value of what is on the right to the variable or element on the left. In your case, there is no variable or element on the left, but instead an interpreted value: you are trying to assign a value to something that isn't a "container".
Based on what you've written, you're just misunderstanding how this operator works. Just switch your operands, like so.
string += str(((t[1])/length) * t[1])
Note that I've wrapped the assigned value in str
in order to convert it into a str
so that it is compatible with the string
variable it is being assigned to. (Numbers and strings can't be added together.)