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