0

Parenthesis

Why in the quiz at return statement there are no parentheses: return y; whereas in the previous sample code there is: return(y); Which one is right? Or both are allowed?

24th Oct 2018, 8:21 PM
Věroslav Olič
Věroslav Olič - avatar
4 Respostas
+ 1
Is this about Python? return is not a function but a keyword, you don't need parentheses there. Values separated by comma will be read as a tuple - where you normally have the option not to write (), like: a = 1, 2 or a = (1, 2) which both work.
24th Oct 2018, 10:42 PM
HonFu
HonFu - avatar
0
Hi, no it is about C. Sorry that I didn't mentioned.
25th Oct 2018, 6:22 PM
Věroslav Olič
Věroslav Olič - avatar
0
In C you also need no parentheses (you can return only one value anyway).
25th Oct 2018, 7:39 PM
HonFu
HonFu - avatar
0
Ok, thank you for your answers.
29th Oct 2018, 8:21 PM
Věroslav Olič
Věroslav Olič - avatar