This forum is now read-only. Please use our new forums! Go to forums
5.6 - Check url in station works, but don't validate
Hi,
I make the function parse_station_json
, and works fine (at least for me, if I did nothing wrong):
def parse_station_json(json_obj):
for station in json_obj['station']:
print station['callLetters']['$text']+": "+station['marketCity']['$text']+","+station['state']['$text']
print 'Frequency: '+station['frequency']['$text']+" "+station['band']['$text']
if station['url']:
print "\tMP3 Streams: "
But i’m receiving Did you check for a key named url in station? Did you print the text label for mp3 streams?
Are the code wrong? or it’s a bug?
Thanks
Answer 518382b2ccc5a985fe00089f
I think it is explained rather literally, as you need to print “MP3 Streams: “, this way:
My code surely works:
if 'url' in station:
print "MP3 Streams: "
On a side note, part 1 has it all solved.
Answer 50f949edbbc93d3d42003ae3
I tried this [forum 2.x] (http://www.codecademy.com/pt/forum_questions/50efffa672670ce99b0029de), but the syntax
if story['url']: #appear 2 mp3 links of 3 podcasts
works better than
if 'url' in story: #nothing appear
Answer 5104995b53f7ac62570013f6
Maybe take out the \t in ‘print “\tMP3 Streams: “
I had ‘Stream’ and it didn’t validate. Computers, too funny. :)
Answer 554eaa80937676c2940000c5
I found that
print(“MP3 Streams: “)
doesn’t count as correct but
print “MP3 Streams: “
does work. As far as I’m aware there shouldn’t be a difference between these.
Answer 55f2ab7d937676f74a0002c9
I have noticed that when I did if url in station it found nothing, obviously, but still good enough to go on to the next lesson
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency