Now I'm down to my 2 for loops. How do I make this into one for loop that basically does the same thing?
def bb_dl_full(l):
for x in range(1,10):
full_url = news_url + "page000" + str(x) + "_i2.jpg"
file_path = yr + mth + days + str(x) + ".jpg"
urllib.request.urlretrieve(full_url,file_path)
print("Fetching page " + str(x))
for x in range(10,l):
full_url = news_url + "page00" + str(x) + "_i2.jpg"
file_path = yr + mth + days + str(x) + ".jpg"
urllib.request.urlretrieve(full_url,file_path)
print("Fetching page " + str(x))
Just introduce an if check inside the for loop, def bb_dl_full(l): if (l < 10): ...do the first part else: ... do the 2nd part
Обсуждают сегодня