Not matching the output with the correct output
<p><a href="https://i.stack.imgur.com/AjdiD.png" rel="nofollow"><img src="https://i.stack.imgur.com/AjdiD.png" alt="enter image description here"></a> </p>

<pre><code>def interpret(result : [None]) -&gt; str:
    s = ''
    s = s + 'Start state = ' + result[0] +'\n '
    for x in result[1:-1]:
        s += ' Input = ' + x[0]+ '; new possible states = ' + str(sorted(x[1])) + '\n '
    s = s + ' Input = ' + x[0]+ '; new possible states = ' + str(sorted(result[-1][1])) + '\n'
    s = s + 'Stop state(s) = ' + str(sorted(result[-1][1])) 
    return s




           evaluated: Start state = start
  Input = 1; new possible states = ['start']
  Input = 0; new possible states = ['near', 'start']
  Input = 1; new possible states = ['end', 'start']
  Input = 1; new possible states = ['start']
  Input = 0; new possible states = ['near', 'start']
  Input = 0; new possible states = ['end', 'start']
Stop state(s) = ['end', 'start'] == Start state = start
  Input = 1; new possible states = ['start']
  Input = 0; new possible states = ['near', 'start']
  Input = 1; new possible states = ['end', 'start']
  Input = 1; new possible states = ['start']
  Input = 0; new possible states = ['near', 'start']
  Input = 1; new possible states = ['end', 'start']
Stop state(s) = ['end', 'start']
</code></pre>

<p>31 *Error: Failed <code>ndfa.interpret(i) == "Start state = start\n  Input = 1; new possible states = ['start']\n  Input = 0; new possible states = ['near', 'start']\n  Input = 1; new possible states = ['end', 'start']\n  Input = 1; new possible states = ['start']\n  Input = 0; new possible states = ['near', 'start']\n  Input = 1; new possible states = ['end', 'start']\nStop state(s) = ['end', 'start']\n"</code></p>

<p>The function takes a list and returns a string. I need to return the string in the correct format. 
It seems to me that the output I get is the same as the correct output, but it give me an error. Can someone tell me why it is not correct? Many thanks</p>

<p>by the way the input is   <code>['start', ('1', {'start'}), ('0', {'start', 'near'}), ('1', {'end', 'start'}), ('1', {'start'}), ('0', {'start', 'near'}), ('1', {'end', 'start'})]</code></p>

<p>and the correct output is       '"Start state = start\n  Input = 1; new possible states = ['start']\n  Input = 0; new possible states = ['near', 'start']\n  Input = 1; new possible states = ['end', 'start']\n  Input = 1; new possible states = ['start']\n  Input = 0; new possible states = ['near', 'start']\n  Input = 1; new possible states = ['end', 'start']\nStop state(s) = ['end', 'start']\n"`</p>

<p>I added a picture to show the result I got.</p>

<p>I've changed the 6th line of the function from <code>x[0]</code> to <code>result[-1][0]</code>, which seems to work:</p>

<pre><code>def interpret(result : [None]) -&gt; str:
    s = ''
    s = s + 'Start state = ' + result[0] +'\n '
    for x in result[1:-1]:
        s += ' Input = ' + x[0]+ '; new possible states = ' + str(sorted(x[1])) + '\n '
    s += ' Input = ' + result[-1][0] + '; new possible states = ' + str(sorted(result[-1][1])) + '\n'
    s += 'Stop state(s) = ' + str(sorted(result[-1][1])) 
    return s
</code></pre>

python