title: How to accept only 5 inputs using recursion and if loops?
body: <p>I'm trying to create a recursive function using only <code>if</code> statements and recursion that will accept at most 5 inputs. If more than 5 inputs are received, the function returns <code>None</code>. The code I have so far is:</p>
  <pre class="lang-py prettyprint-override"><code>def foo()
    count = 0
    n = int(input())
    if n == 5:
      return n
    elif count != 5:
        count += 1
        return foo()
    else:
      return None
  </code></pre>
  <p>I understand that in each recursive call, count gets reset to 0 and hence, the program runs indefinitely. I just can't figure out how to modify it so that I can accept at most 5 inputs using only <code>if</code> statements and recursion.</p>
  <p><strong>Edit:</strong>
  Global variables are not allowed. The function must not take in any parameters. The function can only make use of strings or mathematical techniques from the <code>math</code> module.</p>