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

How to use APIs with Python Forum

View Course

324 points
0b6212fc2985188817ba9ecd4b046b3c?s=140&d=retro
Submitted by
jested
almost 3 years ago

Minor bug in 5/20 - incorrect code passes

It turns out that if you are learning (like me) and don't correctly call urlopen, this exercise still passes! Spot the mistake below:

from urllib2 import urlopen

# Open http://placekitten.com/ for reading on line 4!
kittens = urlopen http://placekitten.com

response = kittens.read()
body = response[559:1000]

# Add your 'print' statement here!
print body

Line 4 should be:

kittens = urlopen('http://placekitten.com')

but without the correct syntax the exercise still passes, despite the console displaying:

  File "python", line 4
    kittens = urlopen http://placekitten.com
                         ^
SyntaxError: invalid syntax

0 votes

permalink

The same mistake doesn't pass in 6/20...but this does!

kittens = requests.get(http://placekitten.com/)

which returns:

  File "python", line 4
    kittens = requests.get(http://placekitten.com/)
                               ^
SyntaxError: invalid syntax

Perhaps the exercise software needs to check that the ASCII cat is actually downloaded?

324 points
0b6212fc2985188817ba9ecd4b046b3c?s=140&d=retro
Submitted by
jested
almost 3 years ago