1

Possible Duplicate:
SyntaxError near “print”?

I've a very weird syntax error right now in python.. Here is the part of code:

tradeID = contract.get('tradeId')
itemID = contract.get('itemData').get('id')
if client.buyItem(tradeID, 200):
    print 'Bought Contract for 200 coins'
    if client.moveCard(str(itemID), 'trade'):
        client.postTrade(str(itemID), str(250), str(0), str(3600))
        print 'Contract posted For 250 Coins'

It says syntax error for the line print 'Bought Contract for 200 coins'

Community
  • 1
  • 1
user1886471
  • 21
  • 1
  • 1
  • 2
  • 2
    Please edit this post and correct the indentation. Since Python is whitespace sensative, we can't help you effectively. Also, what version of Python is this? – thegrinner Dec 07 '12 at 19:49
  • 4
    is this python 2 or 3? print has changed to a function in python 3. – Doug T. Dec 07 '12 at 19:50
  • @DougT. If it was Python 3, it would raise a SybtaxError at the first print not the second one. **Edit**: oh.... it does... – jadkik94 Dec 07 '12 at 19:52
  • What is the point of `str(250)`? Use `'250'` instead directly. – jadkik94 Dec 07 '12 at 19:53
  • 1
    It is possible that you corrected the syntax error when you posted the code here. Check the line *before* the print statement to check if you have enough closing parenthesis (`)`) to match all the opening parenthesis you have (`(`). – Martijn Pieters Dec 07 '12 at 19:56

1 Answers1

0

If you're using Python3, you need to treat print like a function:

print('Contract posted For 250 Coins')

You can use the automated 2to3 conversion script to generate a diff that will correct most problems like this one.

Ken Kinder
  • 12,654
  • 6
  • 50
  • 70