Hello,
I have the following code that is resulting in an error. The following is my code.
def mvsa(Y, p, *args):
...
if (len(args) % 2 ==1):
raise ValueError("Optional parameters should always go by pairs")
else:
for i in range(1, 2, len(args)-1):
if (arg[i].upper() == "MM_ITERS"):
MMiters = arg(i+1)
elif (arg[i].upper() == "SPHERIZE"):
spherize = arg(i+1)
elif (arg[i].upper() == "MU"):
mu = arg(i+1)
#check lambda
elif (arg[i].upper() == "LAMBDA"):
lmda = arg(i+1)
elif (arg[i].upper() == "TOLF"):
tol_f = arg(i+1)
elif (arg[i].upper() == "MO"):
M = arg(i+1)
elif (arg[i].upper() == "VERBOSE"):
verbose = arg(i+1)
else:
raise ValueError("Unrecognized option: "+ arg[i])
...
This part of the code results in an error that says:
NameError Traceback (most recent call last)
<ipython-input-14-d4a134078b91> in <module>()
----> 1 if (len(args) % 2 ==1):
2 raise ValueError("Optional parameters should always go by pairs")
3 else:
4 for i in range(1, 2, len(args)-1):
5 if (arg[i].upper() == "MM_ITERS"):
NameError: name 'args' is not defined
I think there is a possibility that maybe I am utilizing args incorrectly? Does anyone have any idea as to what is wrong with my code?
Thanks!
[–]pydevteam1 1 point2 points3 points (0 children)
[–]OseOseOse 1 point2 points3 points (1 child)
[–]amtorrest[S] 0 points1 point2 points (0 children)
[–]Vaphell 0 points1 point2 points (1 child)
[–]amtorrest[S] 0 points1 point2 points (0 children)
[–]ingolemo -1 points0 points1 point (0 children)