So I'm currently making a tic tack toe game where you play against the computer, and I can't seem to figure this part out. I want the computer to select a random variable from a list of positions that haven't been used yet, and make that variable's value O. Here is what I have currently.
#positions is a list of variables that start off = ''
positions = [ul, uc, ur, cl, cc, cr, ll, lc, lr]
comchoice = randrange(0, len(positions))
while positions[comchoice] != '':
comchoice = randrange(0, len(positions))
else:
positions[comchoice] = 'O'
EDIT: This question is different than the one that it is said to be a duplicate of. It is different because it is asking about changing the value of a variable in a list. It's clear in my post that I understood the duplicate post's question with my code.