mercredi 19 juillet 2017

Python item in list not working

I am having an issue with an if statement regarding an item in a list. Here is the code I am using

score = 0
for j in range(0,1):
    for k in range(0,len(split)):
        keyword = str(split[k][1])
        words = texts[j]
        print(keyword,words)
        if str(keyword) in list(words):
            print("true")
            score = score + float(split[k][0])
        else:
            print("false")
        print(score)

Here is the portion of the output where the statement is visibly wrong. What is wrong in the situation?

"now" ['anonym', 'now'] false 0

Aucun commentaire:

Enregistrer un commentaire