title: Time limit exceeded Error - When I try to run Python 3 code
body: <ul>
  <li>Starting to learn Python 3 on HackerRank when I run this code I get
  this error:</li>
  </ul>
  <p><em><strong>Time limit exceeded
  Your code did not execute within the time limits. Please optimize your code. For more information on execution time limits, refer to the environment page</strong></em></p>
  <p>Here is a link to the question on Hackerrank.</p>
  <p><a href="https://www.hackerrank.com/challenges/repeated-string/problem?h_l=interview&amp;playlist_slugs%5B%5D=interview-preparation-kit&amp;playlist_slugs%5B%5D=warmup" rel="nofollow noreferrer">https://www.hackerrank.com/challenges/repeated-string/problem?h_l=interview&amp;playlist_slugs%5B%5D=interview-preparation-kit&amp;playlist_slugs%5B%5D=warmup</a></p>
  <pre><code>#!/bin/python3
  
  import math
  import os
  import random
  import re
  import sys
  
  #
  # Complete the 'repeatedString' function below.
  #
  # The function is expected to return a LONG_INTEGER.
  # The function accepts following parameters:
  #  1. STRING s
  #  2. LONG_INTEGER n
  #
  
  def repeatedString(s, n):
      Write your code here
      i = 0
      aCount = 0
      
      while i &lt;= n:
          if 'a' == s[i]:
              aCount += 1
              ++i
          else:
              ++i
              
              print(aCount)
              return aCount 
  
  if __name__ == '__main__':
      fptr = open(os.environ['OUTPUT_PATH'], 'w')
  
      s = input()
  
      n = int(input().strip())
  
      result = repeatedString(s, n)
  
      fptr.write(str(result) + '\n')
  
      fptr.close()
  
  </code></pre>