[問題] 'NoneType' object is not iterable?
我是從 C++ 轉到 python 這邊來的
一開始有點不習慣的是
function 的 argument 並未指定型別
所以今天碰到了這個問題
傳入一個我認為是 list 的東西
但 python 跟我說這是 non-iterable
code:
=======================
def sd_calculation(component_vector):
# calculate the average
for x in component_vector:
sum += x
average = sum / len(component_vector)
print average
=======================
error msg:
'NoneType' object is not iterable
想請教一下各位板友這該如何解決?
還是說 argument 型別是動態型別
我是真的不小心傳入了一個 non-iterable 的 object?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.160.39.186
→
02/22 12:12, , 1F
02/22 12:12, 1F
Python 近期熱門文章
PTT數位生活區 即時熱門文章