how to get around UnboundLocalError?
<p>I just started programming and tried to write something but (of course) it failed. After I while I got to the real problem: The <code>UnboundLocalError</code>. So to save you from all the rubble around I stripped the code down to this:</p>

<pre><code>def test():
    try:
        i1 = int(i1)
        i2 = int(i2)
    except ValueError:
        print "you failed in typing a number"

def input(): 
    i1 = raw_input('please type a number \n &gt;')
    i2 = raw_input('please type a number \n &gt;')
</code></pre>

<p>Then I wrote down:</p>

<pre><code>&gt;&gt;&gt;input()
please insert a number
&gt; 3
please insert a number
&gt; 2 
&gt;&gt;&gt;test()
</code></pre>

<p>And then I got:</p>

<pre><code>that was not a number
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "&lt;stdin&gt;", line 7, in test
UnboundLocalError: local variable 'i1' referenced before assignment
</code></pre>

<p>How can I solve this in a Pythonic way? Or should I take a whole different way?</p>
