I am learning Python and came across this example:
W = ((0,1,2),(3,4,5),(0,4,8),(2,4,6)) b = ['a','b','c','d','e','f','g','h','i'] for row in W: print b[row[0]], b[row[1]], b[row[2]]
which prints:
abc
def
aei
ceg
I'm trying to understand why!
I get this, for example, for the first time through the extended version:
print b[(0,1,2)[0]], b[(0,1,2)[1]], b[(0,1,2)[2]]
But I do not understand how (0,1,2) interacts. Can anyone suggest an explanation? Thanks.
(this is an abridged version of some tic tac toe code, and it works well, I just don't get this part)