title: Julia Set Python
body: <p>I've trying to make a julia set in python but my output is Nan at some early process. I don't know what causes it.
  Just for the sake of confession: my programming classes are not good, I don't really know what I am doing, this is mostly from what I've learned from Google.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  
  c = complex(1.5,-0.6)
  xli = []
  yli = []
  while True:
      z = c
      for i in range(1,101):
          if abs(z) &gt; 2.0:
              break   
          z = z*z + c
  
      if i&gt;0 and i &lt;100:
          break
  
  xi  = -1.24
  xf = 1.4
  yi = -2.9
  yf = 2.1
  
  #the loop for the julia set 
  for k in range(1,51):
      x = xi + k*(xf-xi)/50   
      for n in range(51):
          y = yi + n*(yf-yi)/50
          z = z+ x + y* 1j 
          print z
          for i in range(51):
              z = z*z + c    #the error is coming from somewhere around here
              if abs(z) &gt; 2:  #not sure if this is correct
                  xli.append(x)
                  yli.append(y)
  
  
  
  plt.plot(xli,yli,'bo')
  plt.show()      
  
  print xli
  print yli
  </code></pre>
  
  <p>Thank you in advance :)</p>