Help me in solving DAA016 problem

My issue

give the correct code please

My code

def partition(a, size_a):
    pivot = a[size_a - 1]
    idx = 0

    for i in range(size_a - 1):
        if a[i] <= pivot:
            a[idx], a[i] = a[i], a[idx]
            idx += 1

    a[idx], a[size_a - 1] = a[size_a - 1], a[idx]

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    partition(a, n)

    for i in range(n):
        print(a[i], end=" ")

    print()


Learning course: Analysis and Design of Algorithms
Problem Link: Partitioning the array in Analysis and Design of Algorithms