import random st1 = 0 st2 = 0 st3 = 3 st2a = 0 anzahl = 0 go = 1 while go == 1: zahl = random.randint(1,2) if st1 == st2: if st2a == st3: go = 0 else: anzahl += 1 st3 = st2 st2 = st1 st2a = st1 st1 = zahl if zahl == 1: print("K") else: print("N") else: anzahl += 1 st3 = st2 st2 = st1 st2a = st1 st1 = zahl if zahl == 1: print("K") else: print("N") print("Took", anzahl, "tries")