1

I'm using feed parser in python and I'm a beginner in python.

for post in d.entries:
    if test_word3 and test_word2 in post.title:
        print(post.title)

What I'm trying to do is make feed parser find a couple of words inside titles in the RSS feeds.

Tiger-222
  • 6,030
  • 3
  • 43
  • 58
adam eliezerov
  • 1,924
  • 2
  • 10
  • 16

1 Answers1

0

Note that and does not distribute across the in operator.

if test_word3 in post.title and
   test_word2 in post.title:

should solve your problem. What you wrote is evaluated as

if test_word3 and (test_word2 in post.title):

... and this turns into ...

if (test_word3 != "") and (test_word2 in post.title):

Simplifying a little ... The Boolean value of a string is whether it's non-empty. The Boolean value of an integer is whether it's non-zero.

Prune
  • 75,308
  • 14
  • 55
  • 76