Reputation: 844
Trying to run the following code:
QPA=[4,5,6,7,8,9]
MT=[2,3,4,5,6,7]
WH=[225,226,230,225,220,222]
Prd=[24,24,24,24,24,24]
MTBR=[7.5,8,9,7,5,6]
mean_v=[]
mean_value=[]
for q in QPA:
for m in MT:
for w in WH:
for MT in MTBR:
mean_v=q*m*w*24/(MT*1000)
mean_value.append(mean_v)
print (mean_value)
Getting the following error:
TypeError: 'int' object is not iterable
Can somebody point out where am I going wrong? Thanks.
Upvotes: 0
Views: 55
Reputation:
The issue is with the same variable repeated twice. Can i suggest you that you use zip
instead of using nested for loops
. This would be a cleaner and concise implementation.
QPA=[4,5,6,7,8,9]
MT=[2,3,4,5,6,7]
WH=[225,226,230,225,220,222]
Prd=[24,24,24,24,24,24]
MTBR=[7.5,8,9,7,5,6]
for q,m,w,mt in zip(QPA,MT,WH,MTBR):
mean_v = q*m*w*24 / (mt*1000)
mean_value.append(mean_v)
Upvotes: 1