in reply to while or for?

This would be a better question if:

  1. You showed us what you want
  2. You showed us what you've tried, and where you're stuck

For 1, either a sample of your desired output using the data supplied, or a clear(er) explanation of your intent, or, better yet, both.

While, re 2, the Monks give generously of their time and wisdom to those who show effort, but tend to frown disapprovingly on those who see the Monastery as a 'free coding machine'