So for a school project we've been asked to code a boggle game on Python (I'm using 2.7.3), and I've come to a dilemma. I'm trying to get my randomly selected letters from an array of 16 hypothetical "cubes" to appear in a 4x4 format (so that there is a square with 16 random letters).
The code can be seen here:
#Boggle array within an array (array of each letter on each cube placed within another array of 16 cube arrays)
DICE = [
["A", "A", "E", "E", "G", "N"],
["A", "B", "B", "J", "O", "O"],
["A", "C", "H", "O", "P", "S"],
["A", "F", "F", "K", "P", "S"],
["A", "O", "O", "T", "T", "W"],
["C", "I", "M", "O", "T", "V"],
["D", "E", "I", "L", "R", "X"],
["H", "L", "N", "N", "R", "Z"],
["D", "I", "S", "T", "T", "Y"],
["E", "E", "G", "H", "N", "W"],
["E", "E", "I", "N", "S", "U"],
["E", "H", "R", "T", "V", "W"],
["E", "I", "O", "S", "S", "T"],
["E", "L", "R", "T", "T", "Y"],
["H", "A", "E", "E", "G", "N"],
["A", "I", "M", "N", "Q", "U"]]
#Code to randomly select letters from the array defined in DICE
from random import choice
for d in DICE:
print choice(d)
As you can see I've used a for loop to select random letters from each line in the DICE array, now I want those 16 randomly selected letters to display as to create the 4x4 grid.
I.e.
a b c d
e f g h
i j k l
m n o p
Thanks in advance!