我最近开始用
Python编码,遇到一个问题,将函数返回的值赋给变量.
class Combolock:
def _init_(self,num1,num2,num3):
self.x = [num1,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对象不是迭代器.