Last modified: Nov 09, 2025 By Alexander Williams

Python docx Lists: Bulleted and Numbered

Python-docx is a powerful library for creating Word documents. It automates document generation tasks. This includes creating professional lists.

Lists organize information clearly. They make documents easier to read. This guide covers bulleted and numbered lists.

Installing python-docx

First, install the library using pip. This is the package manager for Python.


pip install python-docx

After installation, import the module in your script. You are ready to create documents.

Creating a Basic Document

Start by creating a document object. This represents your Word file.


from docx import Document

# Create a new document
doc = Document()

# Add a title
doc.add_heading('Python-docx Lists Guide', 0)

# Save the document
doc.save('lists_document.docx')

The code above creates a blank document. It adds a title and saves the file.

Adding Bulleted Lists

Bulleted lists use symbols for each item. They are perfect for unordered information.

Use the add_paragraph method. Set the style to 'List Bullet'.


# Add bulleted list
doc.add_paragraph('First bullet item', style='List Bullet')
doc.add_paragraph('Second bullet item', style='List Bullet')
doc.add_paragraph('Third bullet item', style='List Bullet')

Each paragraph becomes a bullet point. The style parameter controls the formatting.

Adding Numbered Lists

Numbered lists show sequence or steps. They use numbers instead of bullets.

Use the 'List Number' style with add_paragraph.


# Add numbered list
doc.add_paragraph('First step', style='List Number')
doc.add_paragraph('Second step', style='List Number')
doc.add_paragraph('Third step', style='List Number')

The list automatically numbers each item. This is great for instructions.

Nested Lists

You can create sub-lists within main lists. This adds hierarchy to your content.

Use different list styles for levels. 'List Bullet 2' creates a sub-bullet.


# Main bullet item
main_item = doc.add_paragraph('Main topic', style='List Bullet')

# Sub-items
doc.add_paragraph('Sub-point one', style='List Bullet 2')
doc.add_paragraph('Sub-point two', style='List Bullet 2')

For numbered lists, use 'List Number 2' for the second level.

Customizing List Appearance

Python-docx offers some customization. You can modify list properties.

Access the paragraph's format. Change indentation and spacing.


# Custom list item
paragraph = doc.add_paragraph('Custom list item', style='List Bullet')
paragraph.paragraph_format.left_indent = 0.5  # Inches
paragraph.paragraph_format.space_after = 0.1  # Inches

This controls how the list appears. Adjust to match your document's style.

Complete Example

Here is a full example. It combines different list types.


from docx import Document

doc = Document()
doc.add_heading('Project Requirements', 0)

# Numbered list for steps
doc.add_heading('Implementation Steps:', level=1)
doc.add_paragraph('Gather requirements', style='List Number')
doc.add_paragraph('Design solution', style='List Number')
doc.add_paragraph('Develop code', style='List Number')

# Bulleted list for features
doc.add_heading('Key Features:', level=1)
doc.add_paragraph('User authentication', style='List Bullet')
doc.add_paragraph('Data export', style='List Bullet')
doc.add_paragraph('Report generation', style='List Bullet')

doc.save('project_plan.docx')

This creates a professional document. It uses both list types effectively.

Advanced List Techniques

For complex documents, combine lists with other elements. Add tables or images between lists.

You can also automate list creation from data sources. Use loops to generate lists dynamically.


# Dynamic list from data
features = ['Fast processing', 'Easy integration', 'Secure storage']

for feature in features:
    doc.add_paragraph(feature, style='List Bullet')

This approach saves time. It is perfect for batch generating documents.

Common Issues and Solutions

Sometimes lists don't format correctly. Check your style names carefully.

Ensure you are using the exact style names. 'List Bullet' not 'Bullet List'.

If lists continue numbering incorrectly, restart the numbering. Add a normal paragraph between lists.

Integration with Other Features

Lists work well with other python-docx features. Combine them with headers and page breaks.

You can add lists to tables for organized data. Use them in reports with proper page setup.

For large documents, consider using headers and footers. This maintains consistency across pages.

Best Practices

Keep lists concise. Use parallel structure for items.

Limit list length. Very long lists become hard to read.

Use appropriate list types. Numbered for sequences, bulleted for options.

Conclusion

Python-docx makes list creation simple. It automates document formatting tasks.

You can create both bulleted and numbered lists. Nested lists add organization levels.

Combine lists with other document elements. Create professional reports automatically.

Mastering lists enhances your document automation skills. It is essential for efficient report generation.