-2

I have been trying to use Python's new print formating for days now. It's gotten to the point that I have cut and pasted several book examples in an attempt to examine the issue.

print '{0} and {1}'.format('spam', 'eggs')

Even this example is yielding:

print '{0} and {1}'.format('spam', 'eggs')
                      ^
SyntaxError: invalid syntax

What's going on?

TigerhawkT3
  • 48,464
  • 6
  • 60
  • 97
user34981
  • 37
  • 1
  • 1
  • 5
  • What version of python are you using? If you are using python 3, `print` must be called as a function: https://docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function – Warren Weckesser Dec 24 '15 at 04:15
  • Are you using Python 3? Python 3 requires parentheses around your parameters. – Arc676 Dec 24 '15 at 04:15

1 Answers1

2

Try :

print('{0} and {1}'.format('spam', 'eggs'))

In Python 3 print is not a statement and has to be called as print()

Output:

spam and eggs
astrosyam
  • 857
  • 4
  • 15