C2 W2 Assignment 2 Has Misleading Code Placeholder for Excerise 2

In Excercise 2, we see this hint:

# Update the offset value with the current value from the request you did plus the limit value.
offset = response.None('None').None('None') + None

This is very misleading. If you try to use the offset value from the response, it creates an infinite loop.

So either one of the following is true:

  1. We’re not supposed to literally replace None values here, and instead need to use a completely different approach.
  2. The mock API does not return an updated offset value.

Either way, this assignment needs to be updated.

@yy55pl I tried this lab when the Spotify API was still available and I used this code:

offset = response.get(‘albums’).get(‘offset’) + limit

Can you confirm that you are trying the same? if you are trying the same code but you are getting a problem, then you might be right and the problem could be the mick API.

Please try it and let me know

This thread might be useful re: the mock API.

I was able to figure it out. The problem was I had a bug in the first exercise that was hard to notice.

I still think this lab should be updated. The first function we have to fill out should have some better verification that we’ve implemented it correctly.

@yy55pl Excellent!

I am glad this is working now. I am closing this thread then.

Thanks for your input!

Can you suggest a test that might have caught the error in your code?

(I re-opened the topic)

It would have been beneficial to have a test that shows the request_url value changes when the offset and limit values change.

So maybe have

releases_response = get_new_releases(url=URL_NEW_RELEASES, access_token=token.get('access_token'))

print(releases_response)

releases_response = get_new_releases(url=URL_NEW_RELEASES, access_token=token.get('access_token'), 10, 10)

print(releases_response)

Something along these lines.

Thanks, I’ll submit a support ticket to update that test.