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.
The code I came up with :
#  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) ---> ABABBB    
				
                        
You need to return the given
axiomsifiterations == 0. In this function, you return the argumentaxiomsyou've been given, so that ifiterations == 0, you will return the given, untouched axioms.Then, later on, at the end of your
iteration, ifiterationthere is, the newly created axioms you get from theiterationis transfered intoaxiomsso that you will return the good value, and if need be, the nextiterationwill have the newly created axioms to iterate on. :)