title: Most efficient way to return True or False if a function input is within specified range? (Efficiency Problem)
body: <p>So I just finished a section exam for my Python course and one of the challenge questions given was to write a function that would return True if the function input was within 10 of either 100 or 200.</p>
  <p>I came up with a a function that works, however, I KNOW that I'm missing some efficiency.</p>
  <p>Here is the function I originally tried:</p>
  <pre><code>def numfunc(a):
      range_list = list(range(90,111)) + list(range(190,211))
      for num in range_list:
          if a != num:
              continue
          elif a == num:
              return True
          else:
              return False
  </code></pre>
  <p>The problem with the above code was that it would return True if the number was in range, however, if it wasn't, it would return nothing.</p>
  <p>The function I wrote that finally worked was this:</p>
  <pre><code>def numfunc(a):
      range_list = list(range(90,111)) + list(range(190,211))
      answer = []
      
      for num in range_list:
          if a == num:
              answer.append(True)
              
      if answer == [True]:
          return True
      
      if answer != [True]:
          return False
  </code></pre>
  <p>Keep in mind that I'm using what functions I've either learned myself or have gone over in the course.</p>
  <p>So if anyone can point out why the first block of code wasn't returning False and/or could teach me a more efficient way to accomplish the same thing: I'd love to learn from you.</p>