Python Flask Basics Character Builder Items

Yahya Alshwaily
seal-mask
.a{fill-rule:evenodd;}techdegree
Yahya Alshwaily
Python Development Techdegree Student 5,640 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 63,095 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 5,640 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}}