Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 14 Online
OpenStudy (anonymous):

Just a thought on the print statement, where we have String = hello world, it can be printed with or without brackets, like print String OR print(String) Is there a recommended or preferred way of doing this ?

OpenStudy (anonymous):

You will need quotes for one. Then I think that it depends on the version of Python if the brackets are required or not!

OpenStudy (microbot):

ye i agree with Chris

OpenStudy (anonymous):

No,only quotes used on assigning the value, on printing out see below both ways >>> String = 'hello world' >>> print String hello world >>> print(String) hello world

OpenStudy (microbot):

what chris says is that some older versions might not work without brackets or find brackets wrong. what python version do u use? tbh if i could use both id choose the brackets cause seems more clean that way.

OpenStudy (anonymous):

That's what I thought, seems better with the brackets

OpenStudy (anonymous):

Python 3 requires print (), while Python 2.x is fine with either. I generally see it not using parentheses if it's Python 2.x.

OpenStudy (anonymous):

kTwitch is right and since I use 3.x for a different course I prefer to use the brackets rather than switching back and forth.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Breathless: Spooky witch but cute
6 hours ago 3 Replies 0 Medals
Arriyanalol: help
6 hours ago 10 Replies 2 Medals
Arriyanalol: @tinydinoUwU stop trying to find a argument u blad lil boy
1 day ago 5 Replies 4 Medals
Jaded012023: Please tell me what you all think of this song
9 hours ago 6 Replies 1 Medal
Arriyanalol: bro how
9 hours ago 2 Replies 3 Medals
Arriyanalol: cant wait for the new bluey movie in 2027
1 day ago 12 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!