import random, math
tries = 0
extreme = 5000000
hard = 5000
medium = 1000
easy = 250
beginner = 100
print("Welcome to the number guessing game!")
print("Choose a difficulty: extreme, hard, medium, easy, beginner")
difficult = raw_input()
我在第14行发现错误。 错误是:“试图根据用户选择的难度来更改随机数的范围
Traceback (most recent call last):
File "D:/Programing/Learning/Python/guessGame.py", line 14, in <module>
answer = random.randint(1, int(difficult))
ValueError: invalid literal for int() with base 10: 'easy'
” 我已经改变了它到我以为会工作无果的一切。
answer = random.randint(1, int(difficult))
不同于论坛的网站,我们不使用“谢谢”,或者“任何帮助表示赞赏“,或签名[so]。请参阅“[应该'嗨','谢谢',标语和致敬从帖子中删除?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be - 删除 - 从帖子)。顺便说一句,这是“预先感谢”,而不是“感谢先进”。 –