Control how often the loop runs by coding a range() with the parameter messages as a value.

Make sure to type range(messages).