L(DEA) ={(ha)n! | n>0)

state = "q0"
def Zustandsuebergangsfunktion(symbol):
global state
if state == "q0":
if symbol=="h":
state = "q1"
return True
else:
return False
if state == "q1":
if symbol=="a":
state = "q2"
return True
else:
return False
if state == "q2":
if symbol=="!":
state = "q3"
return True
elif symbol =="h":
state = "q1"
return True
else:
return False
if state == "q3":
return False
def Akzeptor(wort):
global state
for i in range(len(wort)):
testsymbol = wort[i]
aktzustand = Zustandsuebergangsfunktion(testsymbol)
if aktzustand == False:
print("war nix")
return False
if state == "q3":
print("stimmt!")
return True
ergebnis = Akzeptor("hahahaha!")
print(ergebnis)