对于我的第一个项目,我正在制作一个数字游戏,计算机猜测一个数字,用户告诉计算机猜测是否大于,小于或等于他们正在思考的数字。我的代码设置如下:
echo
这基本上就是我所拥有的。它与guessNumber = 0
def greaterThan():
guessNumber += 1
print("Is your number less than, greater than, or equal to ", (100 + (100 / 2 ** guessNumber)))
''' I know my math is wrong here but I'm trying to get the program to work first '''
lessORgreater = input()
''' I have a function for lessThan() and equalTo() '''
lessORgreater.lower()
#pretty sure this needs to be fixed because I don't think it's right
If (lessORgreater == "greater"):
greaterThan()
和lessThan()
非常相似,只是告诉用户计算机赢了。
我得到的错误是
在分配之前引用的局部变量'猜测数'
答案 0 :(得分:0)