Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

Python title

by suresh

The Python title function is used to convert the first character in each word to Uppercase and following characters to Lowercase and return a new string. In this section, we discuss how to write title Function in Python Programming with example.

The string title Function keeps the Non-letters unchanged. The syntax of the title function in Python Programming Language is

String_Value.title()

String_Value: Please select a valid String variable, or you can use the String directly.

Python title method Example

The following set of examples help you understand the string title Function.

# Python Title() Method Example

Str1 = 'learn PYTHON AT tutOrial gateWay'
Str2 = Str1.title()
print('First Output after Title() method is = ', Str2)

# Observe the Original String
print('Converted String is = ', Str1.title())
print('Original String is = ', Str1)

# Performing title() function directly
Str3 = 'pYTHON proGramminG'.title()
print('Second Output after Title() method is = ', Str3)

Str4 = 'pyTHon 1234 tuTorIal'.title()
print('Third Output after Title() method is = ', Str4)

Str5 = '12345'.title()
print('Fourth Output after Title() method is = ', Str5)
Python Title

First, we declared the String variable Str1 and assigned the following statement

Str1 = 'learn PYTHON AT tutOrial gateWay'

It converts the above string into title case using title function and prints the output.

Str2 = Str1.title()
print('First Output after Title() method is = ', Str2)

The string title function in Python returns the output in a new string instead of altering the original string.

print('Converted String is = ', Str1.title())
print('Original String is = ', Str1)

See that the original string Str1 is unchanged. If you want to change the original String, then you can write the following Python statement

Str1 = Str1.title()

The string titlecase function in Python only converts the first letter of each word into Uppercase. And convert the following words into lowercase, but it leaves other values unchanged. Within the following statements, we used the numeric values along with letters, and you can see the String Method output for further reference.

Str4 = 'pyTHon 1234 tuTorIal'.title()
print('Third Output after Title() method is = ', Str4)

Str5 = '12345'.title()
print('Fourth Output after Title() method is = ', Str5)

Placed Under: Python

  • Download and Install Python
  • Python Arithmetic Operators
  • Python Assignment Operators
  • Python Bitwise Operators
  • Python Comparison Operators
  • Python Logical Operators
  • Python If Statement
  • Python If Else
  • Python Elif Statement
  • Python Nested If
  • Python For Loop
  • Python While Loop
  • Python Break
  • Python Continue
  • Python Dictionary
  • Python datetime
  • Python String
  • Python Set
  • Python Tuple
  • Python List
  • Python List Comprehensions
  • Python Lambda Function
  • Python Functions
  • Python Types of Functions
  • Python Iterator
  • Python File Handling
  • Python Directory
  • Python Class
  • Python classmethod
  • Python Inheritance
  • Python Method Overriding
  • Python Static Method
  • Connect Python and SQL Server
  • Python SQL Create DB
  • Python SQL Select Top
  • Python SQL Where Clause
  • Python SQL Order By
  • Python SQL Select Statement
  • Python len Function
  • Python max Function
  • Python map Function
  • Python print Function
  • Python sort Function
  • Python range Function
  • Python zip Function
  • Python Math Functions
  • Python String Functions
  • Python List Functions
  • Python NumPy Array
  • NumPy Aggregate Functions
  • NumPy Arithmetic Operations
  • Python Numpy Bitwise operators
  • Numpy Comparison Operators
  • Numpy Exponential Functions
  • Python Numpy logical operators
  • Python numpy String Functions
  • NumPy Trigonometric Functions
  • Python random Array
  • Python numpy concatenate
  • Python numpy Array shape
  • Python pandas DataFrame
  • Pandas DataFrame plot
  • Python Series
  • Python matplotlib Histogram
  • Python matplotlib Scatter Plot
  • Python matplotlib Pie Chart
  • Python matplotlib Bar Chart
  • Python List Length
  • Python sort List Function
  • Python String Concatenation
  • Python String Length
  • Python substring
  • Python Programming Examples

Copyright © 2021 · All Rights Reserved by Suresh

About Us | Contact Us | Privacy Policy