by swapping the adjacent elements in exactly two iterationsthe largest number ends up at the last position on the list the if statement makes sure that no needless swaps occur if two adjacent elements are already in the right order the inner for loop only causes the swapping of adjacent elements to occur exactly twice in our list howeveryou'll realize that the running of the for loop for the first time does not entirely sort our list how many times does this swapping operation have to occur in order for the entire list to be sortedif we repeat the whole process of swapping the adjacent elements number of timesthe list will be sorted an outer loop is used to make this happen the swapping of elements in the list results in the following dynamicswe recognize that total of four comparisons at most were needed to get our list sorted thereforeboth inner and outer loops have to run len(unordered_list)- times for all elements to be sortediteration_number len(unordered_list)- for in range(iteration_number)for in range(iteration_number)if unordered_list[junordered_list[ + ]temp unordered_list[junordered_list[junordered_list[ + unordered_list[ + temp