User blog:QuasarBooster/What's wrong with my code?

I recently discovered self-modifying bitwise cyclic tag and started making a program that stimulates its behavior. from console import clear

def SBCT(program): index=0 t=0 while program: clear print('Step %d:'%t) print(program) print(' '*index+'^')

h=int(program[index]) if h==0: #deletes first program bit

program=program[1:] if program:index%=len(program) else: #appends the appropriate bit if the first bit is one

index=(index+2)%len(program) program+=int(program[0])*h*program[(index-1)%len(program)] t+=1

word='1011110111' SBCT(word) It seems to match the behavior for the example string (defined here as ) given on the language's page, as well as for smaller examples as far as I can tell. The issue is that it seems to mess up in the long-term for the given example. On the page it says the program terminates in 43074 steps but it doesn't seem to terminate with my code. Since more steps weren't provided for me to check against, I can't tell how I made a mistake. Could somebody please point out where I'm going wrong if they see it?