I get an error when I execute the code below, but I don't know where to improve it.
Dis_sample=[]
for_in range(10):
PP=np.random.choice (P_sample_all.shape[0], 2, replace=False)
PP_sample.append(PP)
Dis=np.sqrt((P_sample_all [PP[0],0]-P_sample_all [PP[1],0])**2+
(P_sample_all[PP[0],1]-P_sample_all[PP[1],1])**2+
(P_sample_all[PP[0],2]-P_sample_all[PP[1],2])**2)
Dis_sample.append(Dis)
This is the error.
Dis=np.sqrt(P_sample_all[PP[0],0]-P_sample_all[PP[1],0])**2+
^
SyntaxError: invalid character identifier
Additional
If you run the error part outside of the for statement, it works.
Full-width spaces are used to indent the line.
Please correct it to a half-width blank.
Comment ready:
Come to think of it, the blank line right before the error line is three half-width blank, which seems to be different from other lines, but will that affect you?Try arranging it.
The problem was that the line feed created a connection with the previous sentence, and the part that defined Dis was not reflected in the variable definition.
Improved by erasing blank lines between previous sentences.After that, the error no longer appears when I try to break the line again.
549 PHP ssh2_scp_send fails to send files as intended
542 Unable to install versioned in Google Colab
537 Uncaught (inpromise) Error on Electron: An object could not be cloned
709 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
547 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.