赞
踩
这个问题已经在这里有了答案:????????????>????????????error in python d not defined.????????????????????????????????????3个
这是我的代码:
#This is a game to guess a random number.
import random
guessTaken = 0
print("Hello! What's your name kid")
myName = input()
number = random.randint(1,20)
print("Well, " + myName + ", I'm thinking of a number between 1 and 20.")
while guessTaken < 6:
print("Take a guess.")
guess = input()
guess = int(guess)
guessTaken = guessTaken + 1
if guess < number:
print("You guessed a little bit too low.")
if guess > number:
print("You guessed a little too high.")
if guess == number:
break
if guess == number:
guessTaken = str(guessTaken)
print("Well done " + myName + "! You guessed the number in " + guessTaken + " guesses!")
if guess != number:
number = str(number)
print("No dice kid. I was thinking of this number: " + number)
这是我得到的错误:
Name error: Name 's' is not defined.
我认为问题可能是我安装了Python 3,但是该程序正在由Python 2.6解释.我正在使用Linux Mint,如果这可以帮助你们帮助我.
使用Geany作为IDE,然后按F5进行测试.默认情况下,它可能正在加载2.6,但我真的不知道. ?
编辑:
错误1是:
File "GuessingGame.py", line 8, in
myName = input()
错误2为:
File , line 1, in
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。