Python Project Thread Shed

Can someone please explain to me step by step on number 18 and 19? The instructor in video is so confusing. He didn’t explain why two loops were needed… If there is a better video out there, please share it with me . Thank you.

Here is the link to the YouTube video: (Python Project Thread Shed - YouTube)