I need help How do you put words into a 3x3 grid
this is the code i have got so far
random.shuffle(words)
print[0-3]
print (words)
I need help How do you put words into a 3x3 grid
this is the code i have got so far
random.shuffle(words)
print[0-3]
print (words)
import random
words = ["a", "b", "c", "d", "e", "f", "g", "h", "i"]
random.shuffle(words)
grouped = [words[i:i+3] for i in range(0, len(words), 3)]
for l in grouped:
print "".join("{:<10}".format(x) for x in l)
Output:
e h b
i c g
a d f
Remove the random.shuffle(words)
line if you need the original a,b,c,d,etc
order.