How do I successfully include a definition in a if function
<p>How do I put a definition function into a <code>if</code> statement so when it's running the program will activate the definition by itself.</p>

<pre><code>person=int(input("select the number of  any option which you would like to execute:"))

if (person)==(1):
    print ("please write the value for each class ")
    main()

def main ():
    juvenile=(input(" number of juveniles: "))
    adult= (input(" number of adults:"))
    senile=(input("number of seniles:"))
</code></pre>

<p>When i run it it always gives me an error.</p>

<pre><code>Traceback (most recent call last):
  File "C:\Users\fenis\Desktop\TEST PAGE 4 GCSE CS CW.py", line 6, in &lt;module&gt;
    main()
NameError: name 'main' is not defined
&gt;&gt;&gt; 
</code></pre>

<p>You can't call <code>main()</code> at a point where <code>main()</code> hasn't been defined. Move your definition of <code>main()</code> to above the place where you try and call it.</p>

<pre><code>def main():
    juvenile = input("number of juveniles:")
    adult = input("number of adults:")
    senile = input("number of seniles:")

person = int(input("select the number of any option which you would like to execute:"))

if person==1:
    print ("please write the value for each class ")
    main()
</code></pre>

python