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

How to use APIs with Python Forum

View Course

803 points
5287914d80ff33c79300504e_310605451
Submitted by
Svitri Magnusson
almost 3 years ago

Difference between response.status_code & print response

import requests
response = requests.get('http://placekitten.com/')
# Add your code below!
response.status_code

print response.status_code works also, but I could not pass using just print reponse. Why?


0 votes

permalink

I set it to a variable to print it. Just like how the request.get() method is set to the
variable 'response'.

status = response.status_code
print status

I'm assuming 'response.status_code' by itself will only return a value, but not print it.

747 points
4e1cffcbbf7f2ece4c3abfda4ea1756d?s=140&d=retro
Submitted by
CJ Bradbury
almost 3 years ago


0 votes

permalink

Response variable stores everything from the requests.get().
By calling response.status_code it will only return that 3 digit status code.

401 points
161eea6c05c71a97f4a8d9b0bad920b2?s=140&d=retro
Submitted by
ec05677
over 2 years ago