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


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



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


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