Speed up development with full-stack environments for every branch.

Learn More

Generating a 3x3 grid [Python]

Forked from Basic Python.

7090 Runs 31857 Views 11986 Copies
Saved

Saved

riyadhalnur 6

riyadhalnur
published 3 years ago

    # Define blank list
    board = []
    
    #Generate rows with length of 3
    for row in range(3):
      # Appen a blank list to each row cell
      board.append([])
      for column in range(3):
        # Assign x to each row
        board[row].append('x')
    
    # Function will print board like an actual board
    def print_board(board):
      for row in board:
        print " ".join(row)
    
    print_board(board)
      
    
    Please login/signup to get access to the terminal.

    Your session has timed out.

    Dismiss (the page may not function properly).