My python method isn't working correctly, skipping items in a list (playfair cipher)
<p>I'm trying to write a method that takes a key and an alphabet and creates a playfair cipher box. For those of you that don't know what that is, It takes the key and puts it in a  5 x 5 grid of letters, spilling onto the next line if neccessary, and then adds the rest of the letters of the alphabet. Each letter is only supposed to appear in the box once. I'm trying to do this with a list with 5 internal lists, each with 5 items. the only problem is that where the method is supposed to skip letters, it isn't. Here is the method and the output, can anyone help me?</p>

<pre><code>def makePlayFair(key, alpha):
box = []
#join the key and alphabet string so that you only have to itterate over one string
keyAlpha = ""
keyAlpha = keyAlpha.join([key, alpha])
ind = 0
for lines in range(5):
    line = []
    while len(line) &lt; 5:
        if isIn(keyAlpha[ind], box) or isIn(keyAlpha[ind], line):
            print(isIn(keyAlpha[ind],box))
            ind += 1
            continue
        else:
            line.append(keyAlpha[ind])
            ind += 1
    box.append(line)
return box

def isIn(item, block):
    there = None
    for each_item in block:

        if type(each_item) == type([]):
            for nested_item in each_item:
                if item == nested_item:
                    there = True
                    break
                else:
                    there = False
        else:       
            if item == each_item:
                there = True
                break
            else:
                there = False
    return there

&gt;&gt;&gt; makePlayFair("hello", alphabet) #alphabet is a string with all the letters in it

&gt; `[['h', 'e', 'l', 'o', 'a'], ['b', 'c', 'd', 'f', 'g'], ['h', 'i', 'j', 'k', 'l'], ['m', 'n', 'o', 'p', 'q'], ['r', 's', 't', 'u', 'v']]`
</code></pre>

<p>Thanks for your help in advance!</p>

<p>cheers, brad</p>
