I assume that you want help with fixing the exception you get when the script gets into the
The problem here is very simple. You are subtracting an integer from a tuple.
In fact, the bigger mistake here is that you are not using the
range() function properly. You should pass an integer to it for it to work.
The solution is very simple. Change line 10 of your code to:
for arg in range(len(args)-1): The
len() function returns the length of the args tuple.
So, your code will end up like this:
def returnComparison(comparison, *args): # Sample: # returnComparison('greater than', 10, 20, 55) --> 55 if comparison == "greater than": return max(args) elif comparison == "less than": return min(args) else: flag = True for arg in range(len(args)-1): if args[arg] != args[arg+1]: flag = False return flag