title: python functions work sometimes and fail to work other times
body: <p>I wrote the piece of code below a while back, and had this issue then as well. I ignored it at the time and when I came back to it after asking an 'expert' to look at it, it was working fine.</p>
  
  <p>The issue is, sometimes the program seems unable to run the main() on my laptop, possibly due to how heavy the algorithm is. Is there a way around this? I would hate to keep having this problem in the future. The same code is working perfectly on another computer which i have limited access to. </p>
  
  <p>(P.S. laptop having the issue is a MacBook Air 2015 and it should have no problem running the program. Also, it stops after printing "hi")</p>
  
  <p>It does not give and error message, it just doesn't print anything from main(). It's supposed to print a series of strings which progressively converge to "methinks it is like a weasel". In eclipse, it shows that the code is still being processed but it does not output anything that it is supposed to</p>
  
  <pre><code>import random
  
  def generateOne(strlen):
      alphabet = "abcdefghijklmnopqrstuvwxyz "
      res = ""
      for i in range(strlen):
          res = res + alphabet[random.randrange(27)]
      return res
  
  def score(goal, teststring):
      numSame = 0
      for i in range(len(goal)):
          if goal[i] == teststring[i]:
              numSame = numSame + 1
      return numSame / len(goal)
  
  def main():
      goalstring = "methinks it is like a weasel"
      chgoal = [0]*len(goalstring)
      newstring = generateOne(28)
      workingstring = list(newstring)
      countvar = 0
      finalstring = ""
      while score(list(goalstring), workingstring) &lt; 1:
          if score(goalstring, newstring) &gt; 0:
              for j in range(len(goalstring)):
                  if goalstring[j] == newstring[j] and chgoal[j] == 0:
                      workingstring[j] = newstring[j]
                      chgoal[j] = 1
                      finalstring = "".join(workingstring)
                      countvar = countvar + 1
                      print(finalstring)
          newstring = generateOne(28)
      finalstring = "".join(workingstring)
      print(finalstring) 
      print(countvar)
  
  print("hi")
  if __name__ == '__main__':
      main()
  print("ho")
  </code></pre>