Python Forum

Full Version: Invalid syntax error - need help fixing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
j = 0
    while j < 36:
        A[j] = (0.04*(x[j]**2))+(0.04*(y[j]**2))
        print(type(A))
        B[j] = (x[j]**2)+(y[j]**2)
        C[j] = (0.01/(y[j]**2) 
        #Delta[j] = ((2*(math.sqrt((A[j] / B[j]) + C[j])))/Rsq[j])
        j += 1
Error:
runfile('C:/Users/ckirk/.spyder-py3/Labs semester 2 week 3/program.py', wdir='C:/Users/ckirk/.spyder-py3/Labs semester 2 week 3') File "C:\Users\ckirk\.spyder-py3\Labs semester 2 week 3\program.py", line 36 j += 1 ^ SyntaxError: invalid syntax
really don't understand why i'm getting an error here as earlier in the code I did the same thing (with different variables). It even does it for the Delta part (hence why I put it as a comment to try an debug)
A parenthese is missing on the line
C[j] = (0.01/(y[j]**2)
should be
C[j] = (0.01/(y[j]**2))
But please format youe code with tags in the future
(Feb-19-2021, 11:10 AM)Serafim Wrote: [ -> ]A parenthese is missing on the line
C[j] = (0.01/(y[j]**2)
should be
C[j] = (0.01/(y[j]**2))
But please format youe code with tags in the future

oh god sorry Wall Wall I'm sorry i'm new here, I'll try to work out how to do it next time
This is a very common thing you'll see, btw. If there's a SyntaxError, but the line it's complaining about looks fine, then the issue is almost always a missing parenthesis on the previous line.