How does the for loop in python create lists inside list?


for x in range(5):
print board

def print_board(board):
for i in board:
print i

my code is fine, nothing wrong with it. I just fail to understand how the for loop knows that x represents that it has to create a list as opposed to individual elements inside a list. This is confusing me.

Replace this line with your code.


For loops can iterate over lists or dictionaries, but they can also create lists as long as you give the one to work with . Like we've done on this line

So by doing that we create five lists of five O's but to make it nice and clean we use"".join function.
How python changes a user's input into an 'X' is by placing an X on the row and column that the user typed.
So really the for loop just creates the list to work with but its in setting the user's input equal to an 'X'.