input: Write a function to rewrite the given code snippet to find prime numbers using Python. The function should include a nested function that checks if a number is prime or not.
                  
  assert is_prime(7)==True
  assert is_prime(9)==False
  assert is_prime(11)==True
                  
  for n in range(2, 20):
      if is_prime(n):
          print(n)
output: def is_prime(n):
      def check_prime(num):
          if num <= 1:
              return False
          for i in range(2, int(num**0.5) + 1):
              if num % i == 0:
                  return False
          return True
      return check_prime(n)