I would limit the amount of loops it can to do 10 by counting the amount of loops with somehing like `count++` .. then `if count > 10: break`

I'll leave the precise syntax to you as there are many ways to skin that cat!