# # Create a random board for Boggle. # from pprint import pprint import random # Create a new, empty board board = [] # Add the correct number of rows to the board. Removing the 4s and replacing # them with constants is an opportunity to improve this program. for row in range(0, 4): # Append a new, empty, row to the board board.append([]) for col in range(0, 4): # Select a random letter random_letter = random.choice("AAAABCDEEEEEEEFGHIIIIIJKLLLLMNNNNNOOOOPQRRRRSSSSTTTTUUUUVWXYZ") # Add a new column to the current row board[row].append(random_letter) # Display the board with reasonably nice formatting. If we wanted more control # over the formatting we could write a nested for loop to display all of the # elements. pprint(board)