seriouosly elusive for loop (racking my brains!)

Posted by user1693359 on Stack Overflow See other posts from Stack Overflow or by user1693359
Published on 2012-09-24T03:33:45Z Indexed on 2012/09/24 3:37 UTC
Read the original article Hit count: 131

Filed under:
|
|

I've got a loop issue in Python 2.72 that's really frustrating me. Basically the loop is not iterating fast the first index (j), and I've tried all sorts of ways to fix it with no luck.

   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())    

Here is the loop I can't get to iterate. The first for loop only goes through the first iteration of 'j' in the split string list, then removes it from 'missedString'. I would like for all members of the split-string 'recall' to be removed from '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)

I really have no clue, help would be appreciated!

© Stack Overflow or respective owner

Related posts about for-loop

Related posts about python-2.7