My program checks if the first element in the list is an h, if it is then it changes the t to h and h to t, that all works, then it deletes the first element in the list, that works, but why is it not repeating all this code and functions for I in range y times, it only does it once but I want it to do it 3 times, I have tried moving the pop and print function to different positions in the nested loops, but that does not work
x, y=map(int, input().split())
p=list(map(str, input().split()))
for i in range(int(y)):
if p[0]=='H':
for i in range(int(x)):
if p[i]=='H':
p[i]='T'
else:
p[i]='H'
else:
continue
p.pop(0)
print(p)