searching string containing 6 words for real words
<p>I am importing a "dictionary" file containing words that I read in as an array. I then want to search a 6 word phrase being generated by a permutation function for each one of those words and print out if a match is found from the dictionary array to any of the words in the phrase. If I could print out only if it finds matches for the whole phrase that would be preferable. The output of the permutation results in a string of 6 words separated by spaces.</p>

<p>Thanks</p>

<pre><code>import itertools
import array
arr=[]
f = file('/home/kyle/dictionary.csv').readlines()
for i in range(len(f)):
    arr.append(f[i].rstrip('\n').rstrip('\r').split(','))

for a in range(0, len(arr)):
    print arr[a]

s=['e','k','y','a','v','y','a','a','o','s','r','h','t','n','i','k','h','t','s','t','e','n','i','p','p','l','e','h','d','c','t','e','f','a','t','t','l']
for L in range(1, len(s)+1):
for subset in itertools.permutations(s, 37):
    x=( "".join(subset))
    s=x[:5] + ' ' + x[5:]
    s=s[:16] + ' ' + s[16:]
    s=s[:20] + ' ' + s[20:]
    s=s[:27] + ' ' + s[27:]
    s=s[:31] + ' ' + s[31:]
    s=s[:35] + ' ' + s[35:]
    for c in range(0,len(arr)):

        test=str(arr[c])
        if test in s:
            print s
</code></pre>

<p>The bottom part was playing with "in" to find possible matches but that didn't seem to turn out any results. The code is pretty messy</p>
