Prehistory: I just started learning Python and am learning from the book by Zed A. Shaw, "The Easy Way to Learn Python." So, there is a task that needs to be written and executed in the Terminal (I work on a Mac) Here is the code:

# -*- coding: utf-8 -*- import codecs, sys outf = codecs.getwriter('cp866') (sys.stdout, errors = 'replace') sys.stdout = outf age = raw_input("Сколько тебе лет? ") height = raw_input("Каков твой рост? ") weight = raw_input("Сколько ты весишь? ") print "Итак, тебе %r лет, в тебе %r см роста и %r кг веса."  % (age, height, weight) # Выдает SyntaxError: invalid syntax и стрелка, указывающая на ошибку, #где-то впереди, где пусто 

Do not scold strictly if you do not like what I'm learning from this book.

Closed due to the fact that off-topic participants andreymal , freim , Enikeyschik , 0xdb , aleksandr barakin 28 Feb at 15:53 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - andreymal, freim, enikeyschik, 0xdb, aleksandr barakin
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • I run your code. Look carefully, maybe somewhere there is an extra sign, try to copy these particular lines into another file, save and run. - Andrey
  • 2
    Copy the full text of the error and paste it into the question. - Sergey Gornostaev pm
  • I recommend you find a more modern book to study. What you are studying now will become useless in less than a year pythonclock.org - andreymal
  • Well, the problem is really obvious: you wrote the code for the second python, and you start the third one - andreymal

1 answer 1

Most likely, you have a third version of python.

To check this, the last line needs to be changed like this:

 print("Итак, тебе %r лет, в тебе %r см роста и %r кг веса." % (age, height, weight)) 

If it works, then I'm right, and you will need to either put yourself a second version of python, or deal with a more modern book.

  • @ Enikeyschik if after a print there is a percent sign and a bracket (and they are in the author’s code), then the direct text about print without brackets for some reason disappears. So this answer may well be correct - andreymal pm
  • @andreymal yes, launched third, it is. - Enikeyschik