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
Exclamation Invalid syntax error(Predict Ethereum Price) lulu43366 2 97 Sep-24-2021, 01:24 PM
Last Post: lulu43366
  Line 42 syntax error..Help!!1 patpython 4 277 Sep-01-2021, 03:22 PM
Last Post: deanhystad
  Unexplained Invalid syntax Error cybertooth 5 362 Aug-02-2021, 10:05 AM
Last Post: cybertooth
  I have a syntax error! rohes_kaugummi 3 534 Jun-23-2021, 05:24 PM
Last Post: deanhystad
  import module with syntax error Skaperen 7 609 Jun-22-2021, 10:38 AM
Last Post: Skaperen
Heart near "(": syntax error Maryan 3 746 Jun-21-2021, 08:05 AM
Last Post: ibreeden
Exclamation getting a syntax error and i don't know why ilikedofs 10 1,087 May-13-2021, 08:52 PM
Last Post: deanhystad
  [split] SyntaxError: invalid syntax Code_X 3 604 May-04-2021, 05:15 PM
Last Post: Yoriz
  Even number code syntax error MrCeez 1 575 May-02-2021, 06:43 PM
Last Post: Larz60+
  error in your SQL syntax Xuli 10 1,006 May-02-2021, 12:27 PM
Last Post: Xuli

Forum Jump:

User Panel Messages

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