I am struggling to understand how to create a word search puzzle using modules and 2d arrays. So far for the grid I have the following - what I do not know is how to create a for loop to get rid of the commas between the random letters or how to get Letters at the top of teh column... it should be A-whatever at the top and 1 to what ever down the left hand side.
[import sys
import random
seq='abcdefghijklmnopqrstuvwxyz'
#print random.choice(seq)
def populate_array(rows, columns):
array_dic = {}
for row in range(1, rows+1): ## starts with one, not zero
array_dic[row] = []
for col in range(0, columns):
array_dic[row].append(random.choice(seq))
return array_dic
if __name__ == "__main__":
rows = 10
columns = 10
ret_dic = populate_array(rows, columns)
for key in ret_dic.keys():
print key, ret_dic[key]
]
This post has been edited by jam jam: 03 April 2009 - 02:57 PM

New Topic/Question
Reply




MultiQuote



|