What does if any() do in Python?

Please try to make your code a bit readable. Too many for and you can still stretch the below code.

import feedparser
d = feedparser.parse('feed0.rss', 'r')
with open("./mystuff.txt", 'r') as mystuff:
    lines = mystuff.readlines()
    for line in lines:
        for post in d.entries:  
            if (post.title in line):
                print("Here is one: {0} {1}".format(post.title, post.link))

After that you can close the file too. Regarding point 2) the last for loop in parenthesis was completely wrong and give you multiple times the same output.
Please let me know if this solve your exercise.

The line you find will work alone, it is a short way to compress everything in one line. Before you should only iterate on the posts:

for post in d.entries:
    if any(post.title in myline for myline in mylines):
        print("Here is one: {0} {1}".format(post.title, post.link))

where mylines is a mystuff.readlines().
Hope this help you in the understanding.

Leave a Comment