Convert string to title case

Title case

We can format a string to title case with title method. The title method has the following syntax.

s.title()

It returns a title-cased version of the string: words start with uppercase characters; all remaining cased characters are lowercase.


quote = "Python is easy to use."
# from w ww. ja  va2 s .  com
print "Original quote:"
print quote

print "\nAs a title:"
print quote.title()

print "\nOriginal quote is still:"
print quote

The code above generates the following result.





















Home »
  Python »
    Data Types »




Data Types
String
String Format
Tuple
List
Set
Dictionary