dimanche 7 juin 2020

How to traverse a list in 'if loop'

I have trying to traverse the value of i as in the list corpus but everytime it doesnt satisfy the if condition, it exits the loop.

for word in vocab:
    print(word)
        #   print("in loop")
    if word in corpus[i]:
        print(corpus[i])
        count = count + 1
        print(i,count)
    else :
        i = i+1

Here i am trying to increase the value of i by 1 without the loop exiting the if loop and starting with the for loop. Please help.

Aucun commentaire:

Enregistrer un commentaire