Why must I use the parentheses when using print ? Can't I just print " Helloworld " instead ? It works on my laptop coding | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why must I use the parentheses when using print ? Can't I just print " Helloworld " instead ? It works on my laptop coding

18th Apr 2018, 7:45 AM
Andy Lau
Andy Lau - avatar
6 Answers
+ 2
Unlike previous versions of python, print is a function and like every function, it needs parentheses. You might be using python 2 in your laptop for it to work without them.
18th Apr 2018, 7:57 AM
CHMD
CHMD - avatar
+ 2
That is one of the major differences between python 2 and 3. just like KINGDX explained, print is now a function in python3. That comes with the advantage to use additional options for printing out to the console and default settings if not mentioned.
18th Apr 2018, 8:02 AM
Marco Polidori
Marco Polidori - avatar
+ 2
Then, your laptop is running Python 2.6 or 2.7. This is the default version that comes pre-installed on all Mac Books. (Note: Never delete this version from your Mac! Use an environment such as anaconda instead).
23rd Apr 2018, 7:23 AM
Johannes
Johannes - avatar
+ 1
I see , I was learning at codecademy.com , never knew I was learning the outdated version haha
18th Apr 2018, 8:05 AM
Andy Lau
Andy Lau - avatar
+ 1
btw thanks guys
18th Apr 2018, 8:05 AM
Andy Lau
Andy Lau - avatar
0
parentheses so that python interpreter knows that its printing a string you can print variable values, returns and numbers without parentheses
18th Apr 2018, 2:10 PM
Markus Kaleton
Markus Kaleton - avatar