我在 Python 2.72 中遇到了一个循环问题,这让我非常沮丧。基本上循环不会在第一个 index 上迭代j
,我已经尝试了各种方法来修复它,但没有运气。
def learn(dataSet):
for i in dataSet.getNext():
recall = raw_input("Enter all members of %s you are able to recall >>> (separated by commas) " % (i.getName()))
missed = i.getMembers()
missedString = []
for a in missed:
missedString.append(a.getName())
这是我无法迭代的循环。第一个 for 循环仅经过j
拆分字符串列表中的第一次迭代,然后将其从missedString
. 我希望将拆分字符串的所有成员recall
从missedString
.
for j in string.split(recall, ','):
if j in missedString:
missedString.remove(j)
continue
for b in missed:
if b.getName() not in missedString:
missed.remove(b)
print 'You missed %d. ' % (len(missed))
if (len(missed)) > 0:
print 'Maybe a hint or two will help...'
for miss in missed:
remind(miss.getSecs(), i.getName(), missed)
如何修复上述代码?