title: How to create a lettered list using docx?
body: <p>I use python for teaching some of my science courses, where I use it to generate unique assignments and tests for students. I've run into an issue that I can't sort out on my own.</p>
  
  <p>I'm trying to make a series of nested lists. For example, I would like to have a numbered question, and then sub parts to the question underneath. For example:</p>
  
  <ol>
  <li>Use the Henderson-Hasselbalch equation to determine pH of the following solutions:<br />
    A. 250 mM Ammonium Chloride<br />
    B. 100 mM Acetic Acid</li>
  </ol>
  
  <p>I've used style "List Number" to create the numbered list, but I can't figure out how to create a custom list that starts with the letters.</p>
  
  <p>Here is what I've got so far:</p>
  
  <pre><code>import sys
  import os
  
  if os.uname()[1] == 'iMac':
      sys.path.append("/Users/mgreene3/Library/Python/2.7/lib/python/site-packages")
  else:
      sys.path.append("/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python")
  
  import numpy as np
  import math
  import random
  import textwrap
  
  from docx import Document
  from docx.shared import Pt, Inches
  from docx.enum.style import WD_STYLE_TYPE
  from docx.text.tabstops import TabStop as ts
  from docx.text.parfmt import ParagraphFormat
  
  assignment = Document()
  ordered = "a"
  
  
  style = assignment.styles["Normal"]
  font = style.font
  font.name = "Calibri"
  font.size = Pt(12)
  style.paragraph_format.space_after = Pt(0)
  
  LetteredList = style.paragraph_format._NumberingStyle(ordered)
  
  sub_style = assignment.styles["ListBullet"]
  sub_font = sub_style.font
  sub_font.name = "Calibri"
  ###sub_style.paragraph_format.style("List")
  sub_font.size = Pt(12)
  sub_style.paragraph_format.left_indent = Inches(1)
  sub_style.paragraph_format.space_before = Pt(0)
  sub_style.paragraph_format.space_after = Pt(40)
  
  doc_heading = assignment.add_paragraph("Name:_______________________")
  doc_heading.add_run("\t" * 4)
  doc_heading.add_run(" " * 12)
  doc_heading.add_run("BIOL444: Biochemistry\t\t\t\t\t\t   ")
  doc_heading.add_run("\n")
  doc_heading.add_run("Take Home 1, v.")
  doc_heading.add_run((str(1).zfill(2)))
  doc_heading.add_run("\n" * 2)
  doc_heading.add_run("Instructions: Complete test (")
  show_work = doc_heading.add_run("show work")
  show_work.bold = True
  show_work.underline = True
  show_work
  doc_heading.add_run("), submit ")
  hard_copy = doc_heading.add_run("hard copy")
  hard_copy.bold = True
  hard_copy.underline = True
  hard_copy
  doc_heading.add_run(" by ")
  doc_heading.add_run("11:59 pm, Friday, February 10").bold =True
  doc_heading.add_run(". Late submissions will ")
  doc_heading.add_run("NOT").bold=True
  doc_heading.add_run(" be accepted.")
  
  
  question1 = assignment.add_paragraph("Using the data for K", style = "List Number")
  question1.add_run("a").font.subscript = True
  question1.add_run(" and pK")
  question1.add_run("a").font.subscript = True
  question1.add_run(" of the following compounds, calculate the concentrations (M) of all ionic species as well as the pH of the following aqueous solutions: ")
  question1.add_run("\n")
  
  question1a = assignment.add_paragraph("100 mM Acetic acid", style = sub_style)
  question1b = assignment.add_paragraph("250 mM NaOH", style = sub_style)
  
  
  assignment.save("TestDocx.docx")
  </code></pre>