当前位置:   article > 正文

python编程为什么总是显示没有定义_运行Python程序时出现问题,错误:未定义名......

python 为什么会出现,类没定义

这个问题已经在这里有了答案:????????????>????????????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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/619969
推荐阅读
相关标签
  

闽ICP备14008679号