[Solved] how to make If statement and for loop work for an empty variable
shouldn’t it be something like this? import urllib import argparse def download_web_image(url): IMAGE = url.rsplit(“https://stackoverflow.com/”,1)[1] urllib.urlretrieve(url, IMAGE) parser = argparse.ArgumentParser() parser.add_argument(“num1”) parser.add_argument(“num2”) parser.add_argument(“num3”) args = parser.parse_args() num3 = args.num3 if not num3: for num3 in range(01,50): download_web_image(“https://www.example.com/{num1}/{num2}/{num3}.jpg”.format(num1=args.num1, num2=args.num2, num3=num3)) else: download_web_image(“https://www.example.com/{num1}/{num2}/{num3}.jpg”.format(num1=args.num1, num2=args.num2, num3=num3)) your complete code is (sorry) a mess.. first you have to define … Read more