When I run this program: (python 3.3.1)
import random
import time
from random import randrange
print(' ')
print('I am thinking of a person...')
time.sleep(1)
print('He or she belongs to this group of people:')
people = 'Alice Elise Jack Jill Ricardo David Jane Sacha Thomas'.split()
loop = 0
while loop != 6:
group = []
person = randrange(0, len(people))
personName = people[person]
int(person)
group.append(personName)
del people[person]
loop = loop + 1
I sometimes get this error message:
Traceback (most recent call last):
File "C:\Users\user\Python\wsda.py", line 132, in <module>
person = randrange(0, len(people))
File "C:\Python33\lib\random.py", line 192, in randrange
raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width))
ValueError: empty range for randrange() (0,0, 0)
Basically i want it to get 6 random names from the variable 'people' and add it to the variable 'group'...
Also this is part of a larger program based on the guess who game... Could someone please tell me how to fix this? Thx