Python help Modify the following template to make the output
Python help!!!
Modify the following template to make the outputs match. For example: When the input is:
The output should be:
Lab 11.9.1: Bubble sort with optimization Submission11.9.1 Load default template. File: main.py 1 def bubble(list): 2 count 0 count2 = 0 # YOUR CODE HERE! # TO HERE return (count, count2) 5 7 9 list= [] 10 whileTrue: 11 val = input() 12 13 14 ist.append(val) 15 16 counts bubble(list) 17 print(list) 18 print(\"It took\", counts [0], \"swaps and\" 19 print(counts1l. \"comparisons to sort it.\") if val \"exit\": breakSolution
Insert this code inside bubble function and define new function swap.
for i in range( len( list ) ):
for k in range( len( list ) - 1, i, -1 ):
count2 = count2 + 1
if ( list[k] < list[k - 1] ):
        swap( A, k, k - 1 )
         count = count + 1
def swap( A, x, y ):
tmp = A[x]
A[x] = A[y]
A[y] = tmp

