I have found the following code from: Finding all possible permutations of a given string in python
it works nicely but I don't understand part of the loop that I've highlighted below:
def permutation(string, step=0):    
    if step == len(string):
        print("".join(string))
    for i in range(step, len(string)):
        print('step:', step, ' i: ', i)
        string_copy = [c for c in string]
        string_copy[step], string_copy[i] = string_copy[i], string_copy[step]
        # print(i, string_copy, step)
        permutation(string_copy, step+1)
        print('step:', step, ' step+1: ', step+1)
print(permutation('ABC'))
when I run it, I understand that the loop starts with i=0, step=0 and every time runs the function for list generated and "step+1". what I don't understand is that after printing the string (step+1=len(string)) how it goes back to step: 1 and then step: 1 and i: 2 in my example below? the output of code for "ABC". the red boxes are parts that I don't understand:

 
    