我最近开始用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