May you please rectify the error in my code

i am getting duplicate values also .how to remove them my code is

Sorting can help try to think in that way.
please mark the doubt as resolved if no further queries.