4

I've converted a code written in Python 2.6 into Python 3 using 2to3. All the syntax changes have been made accordingly, but I still get an error like following:

print('Type: ' + t)
    ^
SyntaxError: invalid syntax

this happens not only with print() but other totally valid codes like self.type(arg)

What could be wrong? I'm using python 3.2 by the way.

Please hlep me out..

2
  • indentations are completely correct as well Commented Mar 1, 2012 at 7:28
  • 3
    Often mysterious syntax errors are the result of an error above -- like a missing ) -- which is only being reported when the first line is found which becomes invalid python. Look at the prior code. [BTW, please cut and paste exactly the error message. It should be 'SyntaxError', not 'Syntax Error', so you must've retyped it or edited it afterwards.] Commented Mar 1, 2012 at 7:32

3 Answers 3

12

The syntax error is likely on the row above. Looks like a missing parenthesis or something.

Sign up to request clarification or add additional context in comments.

Comments

0

Just to demonstrate what the accepted answer is saying,

print('Type: ' + "1")

gives,

Type: 1

Comments

-2

This is true syntax.

print('Type:%d'%t)

1 Comment

Only if t is an integer. What reason do you have to believe it is?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.