I'm making a tictactoe program and I've ran into the problem of accessing a certain list in a list consisting of lists.
sign = '-'
size = 5
def createGamePlan(size, sign):
gamePlan = []
i = 0
row = [sign]*size
while i < size:
gamePlan.append(row)
i += 1
return gamePlan
print (createGamePlan(size, sign))
Above is my code, which returns:
[['-', '-', '-', '-', '-'], ['-', '-', '-', '-', '-'], ['-', '-', '-', '-', '-'], ['-', '-', '-', '-', '-'], ['-', '-', '-', '-', '-']]
For my program to work I need to be able to access one of these lists to swap out a -
with whichever sign needs to replace it.
Also, what would be the best way to go about replacing an element in a list?