Our teacher wants us to put this in a nested loop but didn't explain how to do it at all, can anyone explain this to me with visuals? Step by step would be great, but I understand if that's way too much.


You should always include what you already have done on your own. Otherwise many will fell you're trying to get us to do your homework.
First What programming language are you writing this in...?
How much do you have already...? (Include Code Samples if possible.)
What in particular are you having trouble with...?

Don't forget to do a bit of research on your own. A quick keyword Google, or YouTube search can go a long away.
You will most likely get several different solutions. Remember NOT to copy the code, (Plagiarize), instead I suggest you understand the basic concept then write something you feel is the most efficient solution for your current task.

To get you started I direct you to the below past discussion:
Click Here

Maybe your teacher didn't explain it because (s)he probably wanted you to go through the process of working it out for yourself.
Give it your best shot before askiing for more help here.