0

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**

谢谢 !!!

4

2 回答 2

1

两件事情:

在 python 3 中,raw_input() 已更改input().

此外,print不再是语句而是函数,所以你必须这样做:

print("Well, {0}, I am thinking of a number between 1 and 20")
于 2013-07-03T01:50:25.803 回答
0

我认为最后一行应该是:

print("Well, {0}, I am thinking of a number between 1 and 20".format(name))

这是经过测试的。我对 p3.3 还很陌生,所以请放轻松 :)

于 2013-07-03T01:51:02.857 回答