def wordjumble(Wordlist, Hintlist, score):
wordchoice = getword(Wordlist, Hintlist)
high = len(wordchoice)
low = -len(wordchoice)
for i in range(10):
position = random.randrange(high,low)
print wordchoice[position]
score = wordguess(wordchoice, score)
return score
我收到一个值错误,我的任务是得到一个高位和低位之间的随机数。 我的错误在哪里?ValueError in random.randrange
这里是回溯:
Traceback (most recent call last):
File "E:\Programming\Python\Worksheet 15\test.py", line 54, in
wordjumble(Wordlist, Hintlist, score)
File "E:\Programming\Python\Worksheet 15\test.py", line 49, in wordjumble
position = random.randrange(high,low)
File "E:\Portable Python 2.7.2.1\App\lib\random.py", line 217, in
randrange raise ValueError, "empty range for randrange() (%d,%d, %d)"
% (istart, istop, width) ValueError: empty range for randrange() (7,-7, -14)
是,其中*是*你的错误? :-) ..你能提供你得到的Traceback /错误信息吗? – Levon
阅读[random.randrange](http://docs.python.org/library/random.html#random.randrange)的文档。 –
回溯(最近呼叫最后): 文件“E:\ Programming \ Python \ Worksheet 15 \ test.py”,第54行,在 wordjumble(Wordlist,Hintlist,score) 文件“E:\ Programming \ Python \ Worksheet 15 \ test.py“,第49行,wordjumble position = random.randrange(high,low) 文件”E:\ Portable Python 2.7.2.1 \ App \ lib \ random.py“,第217行,in randrange raise ValueError,“randrange()(%d,%d,%d)的空范围” ValueError:randrange()(7,-7,-14)的空范围 –
Geostigmata