lets break it apart:
Grid[(i*3):(i*3+3)]
this is using list slicing. Let's make it easier and say i is 0. then this is
Grid[0:3]
which is the elements of index 0 to 2, so the first three elements of the list. If i is one, its
Grid[3:6]
elements with index 3 to 5, the center 3 elements.
"\t"
is the tab character, the join()
function puts the preceding string between every element of the list in the parameter. So
print("\t".join(Grid[(i*3):(i*3+3)]))
prints three consecutive elements of the list separated by tabs, then starts a new line.
including the for
-loop, the program prints three lines of 3 elements arranged in a 3x3 grid, with "A1"
in the top left and "C3"
in the bottom right:
A1 A2 A3
B1 B2 B3
C1 C2 C3