リスト
python
1newinitPhi_list=[[0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]
の要素内に新たな値を代入していきたいのですが、訳あって以下のように代入していくときに、
python
1import numpy as np 2import matplotlib.pyplot as plt 3import math 4 5n=5 6x_list=[] 7t_list=[] 8#philist=[] 9 10def xline(x): 11 for i in range(-n,n+1): 12 x_list.append(i) 13 return x_list[x] 14 15def time(t): 16 for i in range(-n,n+1): 17 t_list.append(i) 18 return t_list[t] 19 20def quantumcoin(theta): 21 C = [[np.cos(theta),-np.sin(theta)],[np.sin(theta),np.cos(theta)]] 22 return C 23#print(quantumcoin(3*(math.pi)/12)) 24 25def initPhi(x): 26 phi_list=[] 27 a=1/math.sqrt(2) 28 b=1j/math.sqrt(2) 29 phi = [a,b] 30 othersphi=[0,0] 31 for i in range(-n,n+1): 32 if i == 0: 33 phi_list.append(phi) 34 else: 35 phi_list.append(othersphi) 36 return phi_list[x] 37#print(initPhi(3)) 38newinitPhi_list=[] 39for i in range(-n,n+1): 40 a=[0,0] 41 newinitPhi_list.append(a) 42print(newinitPhi_list) 43for x in range(-n,n+1): #←ここです!! 44 newinitPhi_list(x+1)[0]=initPhi(x)[0] 45 newinitPhi_list(x-1)[1]=initPhi(x)[1]
以下のようなエラーがでてしまいました。
TypeError: 'list' object is not callable
listは上記のようなfor文中の書き方はできないよ。ということなのでしょうか?
どのように修正すればよいのでしょうか?
ご指導の程、宜しくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/06/09 13:01