问题描述
- 能帮我看看这段程序有什么问题吗?为什么运行的时候总是显示invalid syntax?
-
#This is a simple game.
#Coded by Yingxuimport 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 +=1if 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)
解决方案
python么?语法都不对,看下是哪一行报错,仔细检查下。
解决方案二:
print 'well, (0), I am thinking of a number between 1 and 20.'.format(name)类似语句出现错误。
python 3不允许使用上述的print语法,是这样的格式:print(' .... ')
而上述print格式只能在python 2.x上使用
时间: 2024-09-23 11:51:11