Python Forum
Invalid syntax error - need help fixing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Invalid syntax error - need help fixing
j = 0
    while j < 36:
        A[j] = (0.04*(x[j]**2))+(0.04*(y[j]**2))
        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
runfile('C:/Users/ckirk/.spyder-py3/Labs semester 2 week 3/', wdir='C:/Users/ckirk/.spyder-py3/Labs semester 2 week 3') File "C:\Users\ckirk\.spyder-py3\Labs semester 2 week 3\", 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)
buran write Feb-19-2021, 12:35 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
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.

Possibly Related Threads…
Thread Author Replies Views Last Post
  I have a syntax error! rohes_kaugummi 3 326 Jun-23-2021, 05:24 PM
Last Post: deanhystad
  import module with syntax error Skaperen 7 357 Jun-22-2021, 10:38 AM
Last Post: Skaperen
Heart near "(": syntax error Maryan 3 483 Jun-21-2021, 08:05 AM
Last Post: ibreeden
Exclamation getting a syntax error and i don't know why ilikedofs 10 763 May-13-2021, 08:52 PM
Last Post: deanhystad
  [split] SyntaxError: invalid syntax Code_X 3 428 May-04-2021, 05:15 PM
Last Post: Yoriz
  Even number code syntax error MrCeez 1 413 May-02-2021, 06:43 PM
Last Post: Larz60+
  error in your SQL syntax Xuli 10 721 May-02-2021, 12:27 PM
Last Post: Xuli
  Function syntax error Changosoyyo 2 558 Mar-07-2021, 10:42 PM
Last Post: Changosoyyo
  Syntax error on line 29 manwithjeans 3 615 Feb-27-2021, 08:28 AM
Last Post: perfringo
  Why do I get Syntax error? TechNitium 1 470 Jan-22-2021, 12:49 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020