这个关于win 7的python3.3代码,为什么我得到错误:
import random
guesses_made = 0
name = raw_input('Hello! What is your name?\n')
number = random.randint(1, 20)
print "Well, {0}, I am thinking of a number between 1 and 20" # error here !!!
**print "Well, {0}, I am thinking of a number between 1 and 20"
^
SyntaxError: invalid syntax**
谢谢!
答案 0 :(得分:1)
两件事:
在python 3中,raw_input()
has been changed到input()
。
另外,print
is no longer a statement but a function,所以你必须这样做:
print("Well, {0}, I am thinking of a number between 1 and 20")
答案 1 :(得分:0)
我认为最后一行应该是:
print("Well, {0}, I am thinking of a number between 1 and 20".format(name))
这是经过测试的。我对p3.3很新,所以对我很轻松:)