def G(ω, P, t):
  '''INPUT:
  ω: The axiom; A sequence of the keys of V (letters).
  P: A dictionary whose keys are letters and whose values are sequences of letters.
  t: A non-negative integer; The number of iterations; The length of the output - 1.

OUTPUT:
  A tuple of lists.'''
  if t<0 or t%1!=0:
    raise Exception('%s is not a non-negative integer' % t)
  if t>0:#if time is nonzero
    new=ω[0:0]#empty
    for i in ω:
      try:
        new+=P[i]
      except KeyError:
        new+=i
    return (ω,)+G(new,P,t-1)
  return (ω,)#zero does nothing
def run(V,s):
  '''INPUT:
  V: A dictionary whose keys are letters and whose values are functions.
  s: A sequence of letters.
OUTPUT:
  None.'''
  for i in s:
    try:
      V[i]()
    except:
      pass

l=G('T--T--T',{'T':'T+T--T+T'},4)
print('\n\n'.join(l))
from turtle import Turtle
from functools import partial
t=Turtle()#define functions
t.speed(100)
run({'T':partial(t.fd,1),
     '+':partial(t.lt,60),
     '-':partial(t.rt,60)},l[-1])

t.hideturtle()