Sorting question
def sort(A): count=0 for i in range(len(A)): for j in range(i): if A[j]>A[j+1]: temp=A[j] A[j]=A[j+1] A[j+1]=A[j] A[j+1]=temp count+=1 break if count==0: print("yes") else: ("no") A=[3,2,1,4] sort(A) print(A) if count==0: print("yes") else: ("no") Question is i want to sort the given number but first i want to check elements are sorted or not if not then swap but the elements but swap only 1 time if elements taking 2 or more swaps then simply print no. I share my code but my code is giving me error on count is not defined i don't why.