这个Python错误是什么意思?

bla*_*ned 0 python-3.x

这是我的测试代码(Python 3.2)

import random

def singleMatch():
    a = random.randint(1, 5050)
    b = random.randint(1, 5050-a)
    c = 5050-a-b

    h = [a, b, c]
    print(h)
    computer = [841, 842, 3367]

    score = 0

    for i, j in zip(computer, h):
        if i > j:
            score = score + 1

    if score == 2:
        return 1
    else:
        return 0



def match(n):
    matchScore = 0
    for i in range(n):
        s = singleMatch()
        matchScore = matchScore + s
    return matchScore

x = match(10000)
print(x)
Run Code Online (Sandbox Code Playgroud)

当我运行代码时,我有时会收到此错误:

Traceback (most recent call last):
  File "D:\Ercan\blotto.py", line 32, in <module>
    x = match(10000)
  File "D:\Ercan\blotto.py", line 28, in match
    s = singleMatch()
  File "D:\Ercan\blotto.py", line 5, in singleMatch
    b = random.randint(1, 5050-a)
  File "C:\Python32\lib\random.py", line 215, in randint
    return self.randrange(a, b+1)
  File "C:\Python32\lib\random.py", line 193, in randrange
    raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width))
ValueError: empty range for randrange() (1,1, 0)
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚它意味着什么,或者我做错了什么.

Sho*_*kaa 5

您告诉您的程序创建1到5050之间的随机数并将其存储在a中.之后你想获得1到5050-a之间的另一个随机数,现在如果a是5050,你会要求它生成1到0之间的随机数.

参考