Censor Dispenser Project

I’m working on the Censor Dispenser Project and I don’t understand the solution provided. Can someone please explain the entire function to me step-by-step? I’m having trouble following all the loops and what’s going on.

Here’s the link to my code: https://www.codecademy.com/practice/projects/censor-dispenser

Even with the notes, I’m having trouble following everything. Please Help!