+ 1

Is the parentheses necessary in the code of print?

23rd Jun 2017, 9:56 AM
Sankalp Dayal
Sankalp Dayal - avatar
3 Answers
+ 4
In python 3, the parentheses are obligatory, otherwise you get a synthax error.
23rd Jun 2017, 9:58 AM
CHMD
CHMD - avatar
+ 3
In Python before 3 you can ommit the parenthesis, as 'print' is a statement (more than just a buily-in function, as the if/else, while and others basic structures). So, in Python<3 the function way of writting it witj parenthesis is provide by commodity. Since Python 3, 'print' is no more a statement, but a real built-in function, so require parenthesis which becomes mandatory...
23rd Jun 2017, 12:00 PM
visph
visph - avatar
0
Short answer - yes. Longer answer -this is one major difference between python2 and python3. So it is entirely possible that you will find code without parentheses floating around on the Net - it is python2 code. :)
23rd Jun 2017, 1:09 PM
Bogdan Sass
Bogdan Sass - avatar