How to create a tic tac toe cube using a for loop

How to create a tic tac toe cube using a for loop instead of hard coding it