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,677
  • 3
  • 47
  • 60
adam eliezerov
  • 2,185
  • 2
  • 11
  • 17

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
  • 76,765
  • 14
  • 60
  • 81