title: Defining not_equal Function in Python
body: <p>So the assignment is to imagine that python does not have != built in, and to write a function not_equal that takes two parameters and gives the same result as the != operator.</p>
  
  <p>I've written he following code:</p>
  
  <pre><code>def not_equal(x, y):
       if x == 0 or y == 0: #avoid error message for dividing by 0
           if ((y+1)/(x+1)) == 1:
               equal = False
       elif x/y == 1:
           equal = False
       else:
           equal = True
       return equal
  </code></pre>
  
  <p>and tested the following test cases:</p>
  
  <pre><code>print not_equal(3, 4)
  print not_equal(5, 5)
  print not_equal(0, 3)
  print not_equal(4, 0)
  </code></pre>
  
  <p>The first two work, but the second two give me the following error message:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/dvanderknaap/Desktop/My Python Programs/hw2.py", line 73, in &lt;module&gt;
      print not_equal(0, 3)
    File "/Users/dvanderknaap/Desktop/My Python Programs/hw2.py", line 67, in not_equal
      return equal
  UnboundLocalError: local variable 'equal' referenced before assignment
  </code></pre>
  
  <p>Why?</p>