title: Simple L -system in python
body: <p>Hello I'm looking for a way to implement a simple L-system into function in python which would take three arguments : axiom , rules and number of interations(if iterations = 0 output would be previously input axiom). I came up with some code it only works on 1 iteration and I dont know how to implement more.</p>
  
  <p>The code I came up with :</p>
  
  <pre><code>#  x = axiom
  #  y = rules
  #  z would be iterations which I dont know how to implement
  
  def lsystem(x,y):
      output = ''
      for i in x:
          if i in y:
              output += y[i]
          else:
              output += i
      print(output)
  
  rules = { "A" : "ABA" , "B" : "BBB"}
  # output    lsystem("AB",rules) ---&gt; ABABBB    
  </code></pre>