Well, printing the first line you will see nine x in a list, so we are generating a list
test = ['x' for i in range(9)]
print(test)
Output:
['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']
Next: you could simply write it with two loops where in the first one you loop up to 3 times. And let's print again to understand.
for i in range(3):
print(test[i*3: (i+1)*3])
Output:
['x', 'x', 'x']
['x', 'x', 'x']
['x', 'x', 'x']
As you can see from this output we got three rows each having three numbers of x.
Then, it is possible to loop and print something different like this:
for i in range(3):
for row in [test[i*3: (i+1)*3]]:
print('1 ' + ' 2 '.join(row) + ' 3')
Output:
1 x 2 x 2 x 3
1 x 2 x 2 x 3
1 x 2 x 2 x 3
I hope that it does make sense now! Please let me know if you want a specific explanation for anything else?