I'm trying to make the output on the code
input_str = input("Enter Frogs: ") # User types 5 1 3 4 2 <enter>. Do not type the zero. frog_list = [0] for number_str in input_str.split(): frog_list.append(int(number_str)) sorted_frogs = [0] + sorted(frog_list[1:], reverse=True) frog_count = len(frog_list) - 1 print(frog_list, sorted_frogs, frog_count)Currently it show
Output:Enter Frogs: 5 1 3 4 2
[0, 5, 1, 3, 4, 2] [0, 5, 4, 3, 2, 1] 5
[Program finished]
I want the output to show the steps like this instead:Output:Output:
[0, 5, 1, 3, 4, 2]
[2, 5, 1, 3, 4, 0]
[2, 5, 0, 3, 4, 1]
[2, 5, 4, 3, 0, 1]
[0, 5, 4, 3, 2, 1]
Minimum number of moves: 4
Attempt : maybe i can use this, but don't know how to implement itif list[-1] != 1: list[list.index(0)], list[-1] = list[-1], list[list.index(0)] list[-1], list[list.index(1)] = list[list.index(1)], list[-1] if list[-2] != 2: list[list.index(0)], list[-2] = list[-2], list[list.index(0)] list[-1], list[list.index(2)] = list[list.index(2)], list[-1]