我最近開始用Python進行編碼,並遇到了將函數返回的值賦給變量的問題。將函數返回的值賦給Python中的變量
class Combolock:
def _init_(self,num1,num2,num3):
self.x = [num1,num2,num3]
def next(self, state):
print "Enter combination"
combo = raw_input(">")
if combo == self.x[state]:
print "Correct"
return 1
else:
print "Wrong"
return 0
def lock(self):
currentState = 0
while currentState < 2:
temp = next(currentState)
if temp == 1:
currentState = currentState + 1
else:
currentState = 99
print "ALARM"
當我打電話鎖定功能,我得到一個錯誤在該行
temp = next(currentState)
說,一個int對象不是一個迭代器。
明白了,非常感謝! – Hunterhod