如何使用变量来确定要使用列表中的哪个索引

我最近一直在测试我的程序,每次测试时,我都会收到相同的错误消息: IndexError:列表索引超出范围 该代码是

def NewOffer(CurrentOffer, MaximumPrice, y, NoOfBuyers, Buyers):
    x = random.randint(0, NoOfBuyers)
    SelectedBuyer = Buyers[x]
    if CurrentOffer < MaximumPrice[x]:
        CurrentOffer = CurrentOffer + random.randint(1, 500)
        print(str(SelectedBuyer) + " renewed their offer and are now willing to pay £" + 
        str(CurrentOffer) + " for " + str(AuctionedItem))
        x = random.randint(0, NoOfBuyers)
        NewOffer(CurrentOffer, MaximumPrice, y, NoOfBuyers, Buyers)
        time.sleep(3)

唯一一次跳闸的线路是'''SelectedBuyer = Buyers [x]'''。我该如何解决?