I have a function that is taking arguments from a web form (optional, with default values).
async def _overall(ctx,region="All",mode="All"):
await ctx.send("Running Stats... Region: "+region+", Mode: "+mode)
if os.path.isdir(latest_run):
if region=="All":
r="all"
if mode=="All":
m="All-Modes"
jsonfile = latest_run+"/en/"+r+"/Week."+m+".json"
print(jsonfile)
else:
print("Directory not found.")
When I run this, I get:
UnboundLocalError: local variable 'r' referenced before assignment
I have attempted moving the if statements to the outside, but it gives me the same error:
async def _overall(ctx,region="All",mode="All"):
await ctx.send("Running Stats... Region: "+region+", Mode: "+mode)
if region=="All":
r="all"
if mode=="All":
m="All-Modes"
if os.path.isdir(latest_run):
jsonfile = latest_run+"/en/"+r+"/Week."+m+".json"
print(jsonfile)
else:
print("Directory not found.")
Please advise.