SyntaxError: can't assign to operator - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: SyntaxError: can't assign to operator (/thread-16458.html) |
SyntaxError: can't assign to operator - Jomy10 - Feb-28-2019 Hello I'm trying to write a little program for class, but I get an error saying "SyntaxError: can't assign to operator" and I don't know why that is. The code I'm using: n = int (input ('Getal waarvan je het kwadraat wil berekenen: ')) x = 1 kwadraatx = 1 kwadraatxmin1 = 0 while (x < n): kwadraatx - kwadraatxmin1 + 2 = verschil2 kwadraatxplus1 = verschil2 + kwadraatx kwadraatxmin1 = kwadraatx kwadraatx = kwadraatxplus1 x = x + 1 else: kwadraatx - kwadraatxmin1 + 2 = kwadraatxplus1 print ('oplossing: Het kwadraat van ' + str(n) + 'is ' + str(kwadraatxplus1)) The message I get when I run the code: If anyone could tell my why I get this error, I would highly appreciate it . Thanks in advance, Jomy RE: SyntaxError: can't assign to operator - Yoriz - Feb-28-2019 what you are assigning to should be first instead of kwadraatx - kwadraatxmin1 + 2 = verschil2it should be verschil2 = kwadraatx - kwadraatxmin1 + 2 RE: SyntaxError: can't assign to operator - samsonite - Mar-01-2019 Same adjustment at line 12 Cheers
RE: SyntaxError: can't assign to operator - Jomy10 - Mar-02-2019 Ah, thank you both for the help! |