im trying to make a word puzzle project but im having a few problems..
i need a 10x10 grid (list of lists) but the important thing about the grid is that
the user fill the grid in the following way:

a b c
d e f
g h i

for a 3x3 grid (letters of each line are separated by TAB)
and i only manage to fill a list when i press ENTER after every letter..

Another problem is after i found a word on the grid.. lets say i searched for the word
"hi" - it is found in the grid at [2][1] and thats what i want to print... but when i try to print it it prints this way: [ 2 ][ 1 ] ..

any help with those 2 things?

Recommended Answers

All 2 Replies

Tab is not necessary. Try this code, which will accept anything, letters, numbers, equal signs, etc.

ltr_str = raw_input("Enter 10 letters ")
while len(ltr_str) != 10:
    ltr_str = raw_input("Enter 10 letters and 10 letters only ")
printed = 0
for ltr in ltr_str:     ## access each individually
    print ltr,
    printed += 1
    if printed > 2:
        print
        printed = 0
print

If you want to enter words, separate with a comma and then split() the input on the comma. Commas are the most commonly used delimiter.

words_str = "dog, fog, log, bog, gog, hog, jog, nog, rog, tog" # from input
words_list = words_str.split(",")
printed = 0
for word in words_list:
    print word.strip(),
    printed += 1
    if printed > 2:
        print
        printed = 0
print

Another problem is after i found a word on the grid.. lets say i searched for the word
"hi" - it is found in the grid at [2][1] and thats what i want to print... but when i try to print it it prints this way: [ 2 ][ 1 ]

No way to tell without code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.