Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Flask Basics Character Builder Items

Yahya Alshwaily
seal-mask
.a{fill-rule:evenodd;}techdegree
Yahya Alshwaily
Python Development Techdegree Student 7,296 Points

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

Hi,

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>
                </div>

Thanks in advance!

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 67,464 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!!!

Yahya Alshwaily
seal-mask
.a{fill-rule:evenodd;}techdegree
Yahya Alshwaily
Python Development Techdegree Student 7,296 Points

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}}