-8

enter image description here

I am getting the IndexError: list index out of range

  • Hi, and welcome to StackOverflow. Please see [help] and [ask] to learn how to craft an on-topic question.Please *do not* post images of code. Post code as *formatted text in the question itself*. You can copy-and-paste directly from the editor, and then highlight and press ctrl-k for code-formatting – juanpa.arrivillaga Oct 23 '18 at 03:39

1 Answers1

0

First thing you should know is, randint(start, end) function randomly generates number starting from the start to end. So in your case, it generates a number more than what indexes you have in your lists. You can do,

people = randint(0, len(persons)-1)
Rabin Lama Dong
  • 2,422
  • 1
  • 27
  • 33