Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Flask Basics Character Builder Items

What does .title() do in category.title() ?


What does .title() do in category.title() exactly? I removed it and it did not affect the output at all.

<div class="items">
            {% for category, choices in options.items() %}
            {% if category != 'colors' %}

            <div class="grid-100 row">
                <div class="grid-20">
                    <p class='category-title'>{{ category }}</p>

Thanks in advance!

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 68,404 Points

The title() method is part of the str object:

>>> "this is a string".title()
β€˜This Is A String’

You might get similar results using

{{ category|title }}

Post back if you need more help. Good luck!!!

Hi Chris, I forgot what the .title() method does from "Python Basics" course. Thanks for the reminder. Also thank you for this tip {{category|title}}