DigitalZebra
DigitalZebra

Reputation: 41503

What is wrong with this Python code?

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()

Upvotes: 0

Views: 738

Answers (4)

Jakob Bowyer
Jakob Bowyer

Reputation: 34698

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

Upvotes: 1

aaronasterling
aaronasterling

Reputation: 71004

You're using python 3.

use

print("blah")

The print statement turned into the print function in the transition.

Upvotes: 4

Ivo Wetzel
Ivo Wetzel

Reputation: 46745

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

Upvotes: 4

Josh Smeaton
Josh Smeaton

Reputation: 48720

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.

Upvotes: 0

Related Questions