Advertisement
# Signature of title() method
title()
# Python - Method title() Example
# Creating a string
s1 = ('new south wales')
# Printing the original string
print('Value of string : ', s1)
# Calling the title() method on string object
print('Calling the title() method on string : ', s1.title())
Value of string : new south wales
Calling the title() method on string : New South Wales
# Python - Method title() Example
# Creating a string
s1 = ('amazon - the densest forest in the world')
# Printing the original string
print('Original string before calling title() : ', s1)
# Calling the title() method on string object
print('Calling the title() method : ', s1.title())
# Printing the original string
print('Original string after calling title() : ', s1)
Original string before calling title() : amazon - the densest forest in the world
Calling the title() method : Amazon - The Densest Forest In The World
Original string after calling title() : amazon - the densest forest in the world
Advertisement
# Python - title() method example.
# Creating a string
s = 'after a sad day comes a glad day, so don\'t give up!'
# Printing the original string
print('Original string is : ', s)
# Result of calling title() is made to reference by the reference of original string.
s= s.title()
# Old reference variable pointing to the new string
print('Correct title value of string : ', s)
Original string is : after a sad day comes a glad day, so don't give up!
Correct title value of string : After A Sad Day Comes A Glad Day, So Don'T Give Up!
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement