我想從我的函數調用值和代碼與錯誤而失敗:「詮釋」對象沒有屬性__getitem__
int
object has no attribute__getitem__
請解釋,並建議我應該試試。以下是python代碼:
def congruential(a, m, x):
x_0 = x
for i in range (5):
x_0[i] = (a * x_0[i-1]) % m
if x_0[i] == x_0[0]:
break
print 'Value of X0 =', x
print 'Value of a = ', a
print 'Value of m =', m
print 'Numbers in series'
for j in range (4):
print x_0[j]
congruential(11, 16, 7)
鑑於'x_0'是'7'(如'X_0 = x'),你期望'x_0 [i]'做什麼?你希望從這個函數中得到什麼輸出? – jonrsharpe
你爲什麼大叫? *什麼*系列?而且,再一次,你如何看待'7 [0]'應該做什麼? – jonrsharpe