title: Issue in finding smallest and nearest prime number in this program
body: <p>My have task to convert each alphabet to its ASCII value. Then find the nearest prime number of that ASCII value and return back the alphabet. But output string should be in <strong>[a-zA-Z]</strong> only.</p>
  
  <p><strong>My code is :</strong>  </p>
  
  <pre><code>def find_next_prime(n):
      return find_prime_in_range(n, 2*n)
  
  def find_prime_in_range(a, b):
      for p in range(a, b):
          for i in range(2, p):
              if p % i == 0:
                  break
          else:
              return p
      return None
  </code></pre>
  
  <hr>
  
  <pre><code>s = list(raw_input())
  print "Given : ",s
  
  asc = [ord(i) for i in s]
  print "Ascii Values : ",asc
  
  nearest_primes = [find_next_prime(x) for x in asc]
  print 'Nearest_primes : ',nearest_primes
  
  asc = [chr(i) for i in nearest_primes]
  print "Final output : ",''.join(asc)
  </code></pre>
  
  <p><strong>Output I got :</strong></p>
  
  <pre><code>AFREEN
  Given :  ['A', 'F', 'R', 'E', 'E', 'N']
  Ascii Values :  [65, 70, 82, 69, 69, 78]
  Nearest_primes :  [67, 71, 83, 71, 71, 79]
  Final output :  CGSGGO
  </code></pre>
  
  <p><strong>What I want :</strong></p>
  
  <pre><code>AFREEN
  Given :  ['A', 'F', 'R', 'E', 'E', 'N']
  Ascii Values :  [65, 70, 82, 69, 69, 78]
  Nearest_primes :  [67, 71, 83, 67, 67, 79]
  Final output :  CGSCCO
  </code></pre>
  
  <p>So I have the problem in getting <strong>smallest</strong> and <strong>nearest</strong> prime number.</p>
  
  <p>For number 69, both <strong>67</strong> ---69 ---<strong>71</strong> nearest prime numbers, but I need smallest of them. ie <strong>67</strong></p>
  
  <p>Here I have tried statically with <code>find_next_prime</code> method, but it's not the right way to do. How can I achieve this?</p>