This forum is now read-only. Please use our new forums at discuss.codecademy.com.

367 points
D5f8820231525f223287508256eb3e99?s=140&d=retro
Submitted by
Brad Barnett
over 5 years ago

"Check to make sure all your parameters are correct"

I can't for the life of me figure this out...help!

Here's my code:

from urllib2 import urlopen
from urllib import quote

key = "API_KEY"
url = 'http://api.npr.org/query?apiKey='
url += key + '&numResults=3&action=or&requiredAssets=audio&format=Podcast'

npr_id = raw_input("Enter comma-separated NPR IDs or leave blank." )
search_string = raw_input("Enter your search string or leave blank.")
feed_title = raw_input("What's your feed title?")

response = urlopen(url)
output = response.read()
my_feed = open('my_feed.xml', 'w')

if npr_id or search_string:
    raw_input("Hit Enter to download your podcast.")
    if npr_id:
        url = url + "&id=" + npr_id
    if search_string:
        url = url + "&searchTerm=" + quote(search_string)
    if feed_title:
        url = url + "&title=" + quote(feed_title)
    response
    my_feed.write(output)
    my_feed.close()
else: 
    raw_input("You must enter an NPR ID, a search term, or both.")

0 votes

permalink

declare your variables (response, output, my_feed) after the three if statements.
hope that help

1178 points
289618794b88c522efe6694046bb4fb6?s=140&d=retro
Submitted by
Baishen Huang
over 5 years ago


0 votes

permalink

as per on of the comment in this question https://www.codecademy.com/forum_questions/50fde632a087fa3cf1001a35

if you put these input it will pass "123,1345", "finding", "keeping"

662 points
5109a6349d95ddfd21000028_30334257
Submitted by
Giacomo
about 3 years ago