Whats wrong in this code

is it due to the for loop

hello @pranjuldwivedi120568
this question is straight forward.
read array.
call next_permutation on that array.
print the array.

whatever condition mentioned in the problem is already taken care by next_permuation