0

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?

Edited by Zohaq: n/a

3
Contributors
2
Replies
6
Views
6 Years
Discussion Span
Last Post by woooee
0

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.

Edited by woooee: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.