Python: AttributeError: 'int' object has no attribute 'final_stat
<p>I am stuck in a program. I can't post only the part of the code with error because it is dependent on the rest of the code. So, I have posted the complete code in the link below. Just look at like no. 113 and 114. When I am using <code>fs = fsa.final_state</code> it is giving me the error: <code>AttributeError: 'int' object has no attribute 'final_state'</code>. However, I am able to use <code>print("TEST", fsa.final_state)</code> without any error and the output is also correct. Please ask any part of the code you donât understand. Thanks.</p>

<p>Code:
<a href="https://repl.it/Dfey/7" rel="nofollow">https://repl.it/Dfey/7</a></p>

<p>I've looked through your code. On this line here:</p>

<pre><code>print("'%s'\t%s" % (input, NDRecognize(input, days)))
</code></pre>

<p>Your passing the parameter <code>days</code> to <code>NDRecognize</code>. But when I do <code>print(type(days))</code> I get <code>int</code>. However the <code>days</code> parameter is passed through to<code>loop()</code> and then <code>accept_state()</code> as <code>fsa</code> until you try to access one of it's properties, where the error occurs. </p>

<p>In short, your passing an <code>int</code> as fsa, not an actual <code>FSA</code> object. You'll have to create it and then pass that through as a parameter. </p>

<p><strong>EDIT:</strong></p>

<p>Around line 260 you write <code>days = 31</code> which overrides the days declaration from earlier in the program on line 72. You don't redefine <code>months</code> however, which is why it works for <code>months</code> but not for <code>days</code></p>

python class object