This is similar to Arziomβs answer , but the fact is that the Scrabble board will contain spaces between words.
So, suppose your "2D character array" looks like this:
board = [['s','t','a','c','k',' ',' ',' '],
['p',' ',' ','a',' ','c',' ',' '],
['o','v','e','r','f','l','o','w'],
['o',' ','a','t',' ','a',' ','a'],
['n','o','t',' ',' ','m','a','t'],
[' ',' ','e',' ',' ',' ',' ','e'],
[' ',' ','r',' ',' ',' ',' ','r'],
[' ','e','y','e','s',' ',' ',' ']]
You can do the following:
import itertools
rows = (''.join(row) for row in board)
columns = (''.join(column) for column in zip(*board))
words = [word for line in itertools.chain(rows,columns) for word in line.split() if len(word) > 1]
What gives:
['stack', 'overflow', 'at', 'not', 'mat', 'eyes', 'spoon', 'eatery', 'cart', 'clam', 'water']
We do the conversion of each row and column of characters to type strings 'not mat', and then using str.split()to drop the spaces to give us a list of words, dropping all that one letter long.
itertools.chain(), .