[Tutor] how run it on python 3

Peter Otten __peter__ at web.de
Tue Jan 21 00:00:52 CET 2014


S Tareq wrote:

> this is the coding that i am trying to run it on python 3.3. the original
> coding was made on python 2.7 however i have made some changes to the
> coding to make it work on python 3.3. the changes that i have made  on
> brackets and raw_input to input. the coding does not load the external
> file ans says invalid syntax . please help me thank You very much.
> 
> the changed coding:

> print ("Please Select the number which is the correct definition of the
> word:") ,keywords[word] #Generating an new sequence each time different
> from previous one while True:

print is a function in Python 3.
Python 2's statement

print "Please select...", keywords[word]

must be spelt

print("Please select...", keywords[word])

You have added the closing parenthesis too early.

But you should not translate your scripts by hand -- there's a tool called 
2to3 that does the legwork for you.





More information about the Tutor mailing list