Python:13.5 Custom Print


Hello Friends, I have a doubt about is my code

for i in range(0,5):

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

Although my code works fine, I am confused about the declaration of "row" .How does computer understands what "row" is without us declaring it.


But we do 'define' it, in the for statement. It is the declared iterator variable to take each item in the board list, one at a time and in order. These are lists that are independent of one another. It's a convenience to call it a 'row', but also sensible, since that is what it is on the screen.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.