I am getting the IndexError: list index out of range
Asked
Active
Viewed 62 times
-8
-
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 Answers
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
-
Thank you!!! I was wondering if you could also help with the yes or no part too. I'm supposed to make it so that if they say yes the whole program starts over and when they say no it ends the program. – Gerome Miranda Oct 23 '18 at 04:08
-
you can use `input()` function to take input from user in the terminal. If you found the answer helpful then please upvote it and mark it as the best answer. Thank you ! – Rabin Lama Dong Oct 23 '18 at 04:17
-
-