title: xlwt create dynamic number of worksheets based on input
body: <p>I know how to create multiple worksheets and write to them if I know in advance how many worksheets I will need. For example, this code works fine if I only have 3 worksheets. (I can use a for loop to dictate the contents of each worksheet):</p>
  
  <pre><code>import xlwt as xlwt
  
  workbook = xlwt.Workbook()
  style = xlwt.XFStyle()
  
  ws1 = workbook.add_sheet("Worksheet 1")
  ws2 = workbook.add_sheet('Worksheet 2')
  ws3 = workbook.add_sheet('Worksheet 3')
  
  # For loop to dictate contents of each worksheet here...
  worksheet = ws1
  worksheet.write(1, 1, 'Welcome to Worksheet 1', style)
  
  worksheet = ws2
  worksheet.write(1, 1, 'Welcome to Worksheet 2', style)
  
  workbook.save(r'C:\Users\...\Desktop\...\mult_worksheets.xls')
  </code></pre>
  
  <p>However, what I want to do is gather data and create new worksheets that I can write to based on the number of datasets gathered. I won't know ahead of time how many worksheets I will need to create and write to. It may be 1 dataset or up to 10.</p>
  
  <p>I know that worksheet objects are created when you call workbook.add_sheet('Name'). For example:</p>
  
  <pre><code>ws1 = workbook.add_sheet('Worksheet 1')
  </code></pre>
  
  <p>I need the worksheet instance "ws1" in order to write to that worksheet. How can I create only the number of worksheet instances that I need and be able to write to them?</p>
  
  <p>If I gather a set of 4 datasets, I need to create 4 worksheets, with the names of the worksheets and the contents determined by the datasets.</p>
  
  <p>To clarify, lets say I create a list of dataset names like this:</p>
  
  <pre><code>worksheet_names = ['CA Stats', "TX Stats", "NY Stats", "FL Stats"]
  </code></pre>
  
  <p>These will be used as the names of the worksheets.</p>
  
  <p>And each worksheet will have its own data. For example:</p>
  
  <pre><code>worksheet_data = ['Welcome to CA Stats', "Welcome to TX Stats", "Welcome to NY Stats", "Welcome to FL Stats"]
  </code></pre>
  
  <p>Any help is appreciated!</p>