Jun-14-2021, 02:06 PM
I don't see it running forever, but the logic looks odd. I think what you are trying to do is process years up to 1985 using the USA API and from 1985 onward using the Australia API. This is not what your code does. Because the Australia API loop is embedded inside the USA API loop, your code will only call the Australia API if the start year is prior to 1985, and it is called repeatedly, once for each year prior to 1985. I would write the code like this:
for year in range(start_year, end_year+1): # do you want to include end_year? if year < 1985: # USA API else: # Australia API