Some more context would be cool. Do you have more examples of your problem?
If you have cases where your logic works and you don't have two result words, you will get the error you mention because of a None value.