While placing parentheses around the return value is unnecessary, it does not affect the result. Therefore, it should not cause a problem. What error message did you see when the parentheses were included?
@ion_killah, in general, it’s probably considered better form to omit the parentheses with return. Since return is not a function, they are not required, and the (definite, but not overwhelming) preference seems to be to omit them.
return can evaluate and return a sequence, called a tuple, of expressions.
If you have not yet studied the tuple data type, it is a data type consisting of a sequence of items separated by commas. By default, Python prints tuples surrounded by parentheses, leading people to suppose that parentheses are required, but they are not, unless it’s necessary to place them to avoid ambiguity (for instance, if the tuple contains mathematical expressions requiring parentheses.)
# cool things you can do with tuples
t = 5, 7 # tuple packing
print(t, t) # the print function can take a tuple as an argument
a, b = t # tuple unpacking
# Here is a function with multiple expressions in the return statement: a tuple
return x**2, x**3, x**4
q = sq_cube_fourth(5) # call the function
print(q) # this will be a tuple
r, s, t = q # now let's unpack it
(5, 7) # Python adds parentheses
(25, 125, 625) # again with the parentheses
There are other rules, the most important being that you can’t change the items within a tuple, as you can with lists. As with strings, if you need to change something, you must build a new tuple.
Including the parens casts the return value to a tuple, which might not be the expected return from the standpoint of the SCT (or the caller, for that matter). They do have an effect on the return value, make no mistake.
Yeah, by focusing on a pattern in the user’s code rather than directly on the result, the SCT can mislead the user into thinking there was an error, when in fact there was not …
Messages from SCTs should strive to make it clearer whether they are a complaint from the SCT itself or whether they originate from the Python interpreter or even relate to the actual result, especially in the introductory courses. With experience, users can make the distinction, however, learners cannot be expected to recognize the difference right from the start.
Thanks, to all of you for clearing that up. Nice to know its just the backend system checking what I have done, which is sending that response out and not an actual error. For curiosities sake what does SCT?