Hi.
Your code is nice.
May I ask why do you use 2 for loop in this case?

Appreciate your help!