5. Custom Print -- how does it know each row needs to be a diff row?


#1



5. Custom Print


Works fine


Curious how the program understands to iterate each row using "row". Nothing in the code helps it understand each row is its own row. Is it because its a random variable it knows to iterate each program on a separate line? how does it know this without using the \n?


board = []

for i in range(0,5):
    board.append(["O"] * 5)

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

print_board(board)


#2

in python, you define the iterator inside the loop, python will assign (in sequence) each element to row


#3

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