Answers for "title() function in python"

1

title() function in python

# title() title function capitalises the first letter of string and make other 
# letter lower case.
a=input('Enter a string :')
b=a.title()
print(b,': is the modified string')
# output:
'''
Enter a string :hII hOW aRE yOU
Hii How Are You : is the modified string
'''
Posted by: Guest on January-20-2022
2

title() in python

>>> import re
>>> def titlecase(s):
...     return re.sub(rb"[A-Za-z]+('[A-Za-z]+)?",
...                   lambda mo: mo.group(0)[0:1].upper() +
...                              mo.group(0)[1:].lower(),
...                   s)
...
>>> titlecase(b"they're bill's friends.")
b"They're Bill's Friends."
Posted by: Guest on August-11-2021

Python Answers by Framework

Browse Popular Code Answers by Language