how am I supposed to call the function?
<p>I wrote a program which tells you knight's movement (chess).
For example if I wanted to know all possible moves, I'd input:</p>

<p><code>possibilites("F4")</code> and I'd get <code>['D3', 'D5', 'E2', 'E6', 'G2', 'G6', 'H3', 'H5']</code> as a result, ok I did that, next, I had to write a function in which you input two fields and if those fields are legal, you'd get True and if they're not you'd get False(I had to use the previous function).
For example:</p>

<pre><code>legal("F4","D3")
&gt;&gt;&gt;True
</code></pre>

<p>code:</p>

<pre><code>def legal(field1,field2):
  c=possibilities(field1)
  if field1 and field2 in a:
     return True

  return False
</code></pre>

<p>I'm having a problem with the following function which I have to write:
I have to put in path of the knight and my function has to tell me if it's legal path, I'm obliged to use the previous function.</p>

<p>for example:</p>

<pre><code>&gt;&gt;&gt; legal_way(["F3", "E1", "G2", "H4", "F5"])
True
&gt;&gt;&gt; legal_way(["F3", "E1", "G3", "H5"])
False
&gt;&gt;&gt; legal_way(["B4"])
True
</code></pre>

<p>I know I have to loop through the list and put first and second item on it in <code>legal(field1,field2)</code> and if it's false, everything is false, but if it's true I have to continue to the end, and this has to work also if I have only one field.
I'm stuck, what to do?</p>

<pre><code>def legal_way(way): 
   a=len(way) 
   for i in range(0,a-2):
      if a==1:
         return true
      else:
         if legal(way[i],way[i+1]): 
            return True 
         return False 
</code></pre>

<p>and I get True or index out of range</p>
