It would do so if it cannot lookup the symbol. In that case, lookup
returns None
, a special value of type NoneType
indicating absense of something, like proper data.
Since you are looping a list portfolios
, I assume those are symbols of stocks already bought, so they should exist.
That seems a frequent problem currently, the API sometimes not returning the expected data, implementing some kind of cache might help (to reduce the number of requests, or re-use an old response if the request fails). I'm not sure the average student is expected to write such thing.
As far as I know, the check50
and submit50
checkers do not rely on those external services, and inject their own lookup
(to test your code in certain situations, like whether you render a money value with trailing zeroes like $42.00
correctly). So if you are sure your code is right, even though it sometimes fails for this None
response, you might still be able to submit.