Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Marta P.
Marta P.
2,849 Points

Help me tweak this little program I built?

Hello everyone! I managed to build this little program (on my computer, not workspaces) that goes through Reddit's r/gifrecipes and prints the recipes with the ingredient you give. It works quite well, but one thing bugs me terribly.

I can't figure out how to have the program print "No __ recipes yet, I'm afraid" just when there is NO recipe that contains the keyword given by the user. I tried it all with all kinds of loops, but at the moment the closest I can get to it is having the program printing the sentence at the end of the exhaustion of the for loop.

I know the solution is close! Here is my script:

#! /usr/bin/python
import feedparser
import os

page = feedparser.parse("https://www.reddit.com/r/GifRecipes/.rss")

def gifrecipe_finder():
    word = raw_input('\n What do you wanna cook? ')
    for i in page.entries:
        while word in i.title or word in i.link:
            print '\n'
            print ' ' + i.title
            print ' ' + i.link
            print '\n'

    if word not in i.title or word in i.link:
        print '\n No {} recipes yet, I\'m afraid \n'.format(word)

def do_over():
    again = raw_input('\n Still hungry?(y/n) ')
    while again not in ('y', 'n'):
        again_two = raw_input('\n Sorry, didn\'t catch that.(y/n) ')
        if again_two == 'y':
        elif again_two == 'n':
    if again == 'y':
    elif again == 'n':