Can anyone tell me what is wrong with this? I'm getting a syntax error after the 2nd quote on the print line... It seems like this should work perfectly fine. Thanks
def main():
print "blah"
return
main()
4 Answers 4
In case you're using Python 3, the print statement is gone in that version and you need to use the print() function.
See: http://docs.python.org/release/3.0.1/whatsnew/3.0.html#print-is-a-function
Comments
You're using python 3.
use
print("blah")
The print statement turned into the print function in the transition.
Comments
Remember if your using python 2.x then to help with the transition you can always have
from __future__ import print_function
At the top of your code, this will convert print into a function meaning 2.x code can be written with
print('This')
And run happily
Comments
Posting the exact error you get would be very helpful. I'm going to assume that this is an indentation error though. Don't mix tabs and spaces.
print? Are you using Python 3?printis a function, not a statement. Should beprint("blah").