Python Forum

Full Version: coding
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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;
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.
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. :/
(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).
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?