How to Use String title() Method in PythonPython Basics


The title() method returns a string with the first letter of each word capitalized (a title cased string).

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

str = "this is a python website for beginners"
print(str.title())

Output:

This Is A Python Website For Beginners

Syntax

str.title()

Parameters

The method doesn’t take any parameters.

Return Value

It returns a title cased version of the string.

© 2024 Learnwithgpt.org, all rights reserved. Privacy Policy | Contact Us