简体   繁体   中英

Python3 Syntax error

I am quite a new user in python. I am making a script to calculate some quantity like below

A = sum([( f * Rphi[i,i] + Rt[i,i]) * NN[i,i] for i range(0,2)]) + 2*sum([sum([(f * Rphi[i,j] + Rt[i,j]) * NN[i,j] for j in range(i+1,2)]) for i in range(0,1)])

f is defined as scalar value and all two indices quantities are defined as 3x3 matrix in previously.

This is just summing over indices. When I try to compile it, I got:

Error message

在此处输入图片说明

The error indicates that there is a syntax problem in the usage of for I in range(0,1) But I cannot find the problem in there.

Any comments or advice is really appreciated!

Syntax Errors are usually when you make a mistake in the code syntax. In this case, your first part of the code is

sum([( f * Rphi[i,i] + Rt[i,i]) * NN[i,i] for i range(0,2)])

should be

sum([( f * Rphi[i,i] + Rt[i,i]) * NN[i,i] for i in range(0,2)])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM