3

I get the error as in the title of my post. I have seen this come up in other questions, but I am interested in understanding what this means since the other answers were in a specific context that does not apply to me.

Secondly, I would like to understand how this applies to my code, shown below. Note that this all works OK if Zindx = 0, but not for any other case.

    Zindx = list(E).index(0)
    for m in range(0,N):
            if m != Zindx:
                for n in range(0,N):
                    if n != Zindx:
                        if n != m:
                            x[m,m] = x[m,m] (
                            - (E[n]-E[m] + E[n])*x[m,n]*x[n,Zindx]
                            /x[m,Zindx]/E[m]
                            )
2
  • 2
    Your problem is where you do x[m, m] = x[m, m] ( ... ). You probably want to stick a *, or some other operator, between x[m, m] and the (: otherwise, Python is interpreting that as calling object x[m, m] with the arguments inside the parentheses. Commented Sep 23, 2013 at 23:54
  • Now I feel stupid super stupid! Thamks. Commented Sep 24, 2013 at 0:52

1 Answer 1

3

This:

x[m,m] (
    - (E[n]-E[m] + E[n])*x[m,n]*x[n,Zindx]
    /x[m,Zindx]/E[m]
    )

Is trying to call x[m,m] as a function with the expression within the parenthesis as an argument. I am guessing x[m,m] returns a float. Do you mean to multiply x[m,m] by the term in the parenthesis? If so, add the *.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeh, that was very stupid of me. I read that parentheses can be used for equations that run on multiple lines, but clearly this can only work if they are used with the same syntax. I was too busy looking at all the other possibilities that I never noticed...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.