Python Error code: IndexError: index error list index out of range

后端 未结 1 1523
小蘑菇
小蘑菇 2021-01-27 07:15

I\'m trying to write a function in Python that simulates a horse race. While there\'s no winner, it clears the screen, shows the list of horses (all have index starting at zero)

相关标签:
1条回答
  • 2021-01-27 07:25

    random.randint() is inclusive, so if you get a random integer that is equal to HORSE_NUM it will be out of bounds. try

    rando = random.randint(0, HORSE_NUM - 1)
    
    0 讨论(0)
提交回复
热议问题