能帮我看看这段程序有什么问题吗?为什么运行的时候总是显示invalid syntax?

#This is a simple game.
#Coded by Yingxu

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.'.format(name)

while guesses_made<6:
guess=int(raw_input('take a guess:'))
guesses_made +=1

if guess <number:
print 'Your guess is too low'

if guess >number:
    print 'Your guess is too high'

if guess==number:
    break

if guess==number:
print 'Good job, (0)! You guessed my number in (1) guesses!.format(name, guess_made)
else:
print 'Nope. The number I was thinking of was (0)'.format(number)

2个回答

python么?语法都不对,看下是哪一行报错,仔细检查下。

print 'well, (0), I am thinking of a number between 1 and 20.'.format(name)类似语句出现错误。
python 3不允许使用上述的print语法,是这样的格式:print(' .... ')

而上述print格式只能在python 2.x上使用

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问