0

Python print statement

Is this statement valid print "Hello World" because in unix it gets executed but in windows it ask us to put the braces()

20th May 2017, 6:13 AM
shreesh katti
shreesh katti - avatar
4 Antworten
+ 7
#to simplify visphs post further into an example: print "hi" #works in python2.7 print("hi") #works in all python versions
20th May 2017, 6:27 AM
Ahri Fox
Ahri Fox - avatar
+ 7
You can also do this: apples = print apples ("Hi") ... which I think is funny
20th May 2017, 8:26 AM
Michael Foster
Michael Foster - avatar
+ 6
It's not a difference due to OS, but to Python version: Before Python3, 'print' was a statement and could be used as a function ( with the 'braces' () ) Since Python3, it's no more a statement and need to be use as a function call ( with the 'braces' () )
20th May 2017, 6:21 AM
visph
visph - avatar
+ 5
@Ahri: print("hi") # works in all Python versions ;P
20th May 2017, 6:29 AM
visph
visph - avatar