Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
coding
#1
Exclamation 
Hey guys,
I am new to coding and getting some errors. I am sure it is quite simple for someone with more experience.
Thank you for your help

 # create blank datasets
    nparam = 11; #Fill number of parameters
    K = zeros(npool,npool);
    A = zeros(npool,npool); 
    stdev=zeros(Nt,npool);
    J_last= 30000000;
    
    stdev[:,1] = pusd[:,1];
    
    for i in range (1,Nt):
     for j in range (2,npool):
      stdev(i,j) = ppsd(i,j-1);
end
end

    DJ=2*stdev.^2;                      #### IndentationError: unexpected indent
    T1P = zeros(day(Nt),npool);
    T1R = zeros(day(Nt),npool);
    T1C = zeros(day(Nt),npool);
    T1fR = zeros(day(Nt),npool);
    resp_mod1 = zeros(day(Nt),npool);

    params_diff = params_max-params_min;
    f_diff = f_max-f_min;

    params_op = params_init;
    params_new = params_init;
    
    f_op = f_init;
    f_new = f_init;
    
    opo_op = opo_init;
    opo_new = opo_init;
Gribouillis write Dec-06-2021, 11:04 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
Indentation (= the number of spaces in front of a line) is important in Python. You cannot just indent a line for no reason. Please read 3.2. First Steps Towards Programming.
Reply
#3
Hi,
Thanks for your help.
I know the Indentation (= the number of spaces in front of a line), I deleted all possible spaces and still getting the error msg. :/
Reply
#4
Look at https://www.w3schools.com/python/python_for_loops.asp

python loops have no end
ecovrefoltr likes this post
Reply
#5
(Dec-06-2021, 01:42 PM)ecovrefoltr Wrote: I know the Indentation (= the number of spaces in front of a line), I deleted all possible spaces and still getting the error msg
... but I guess you get the error message on a different line. And I did not say you had to remove all possible spaces, because indentation is necessary when using a for-loop. There you had originally correct indentation, although it is recommended to always have a multiple of 4 spaces as indentation.

It is best to always show the code you have and the complete error message (using the correct tags).
Reply
#6
You should also remove all your semicolons and use recommended whitespace in your function arguments. You should review the pep8 style guidelines.

https://www.python.org/dev/peps/pep-0008/

As for the error message being on the wrong line, do you have much programming experience? Errors are reported where the error breaks something, not where the error occurred. Many Python "syntax errors" happened on the line above, or many lines above.

If you are getting error messages why are there no error messages included in your posts?
Reply


Forum Jump:

User Panel Messages

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