Advertisement
# Signature of capitalize() method
capitalize()
# Python - Method capitalize() Example
# Creating a string
s1 = ('new zealand')
# Printing the original string
print('Value of string : ', s1)
# Calling the capitalize() method on string object
print('Calling the capitalize() method on string : ', s1.capitalize())
Value of string : new zealand
Calling the capitalize() method on string : New zealand
# Python - Method capitalize() Example
# Creating a string
s1 = ('mars - The Red Planet')
# Printing the original string
print('Original string before calling capitalize() : ', s1)
# Calling the capitalize() method on string object
print('Calling the capitalize() method : ', s1.capitalize())
# Printing the original string
print('Original string after calling capitalize() : ', s1)
String's value : mars - the red planet
String's upper case value : MARS - THE RED PLANET
String's value : mars - the red planet
Advertisement
# Python - capitalize() method example.
# Creating a string
s = 'you have got to live your life!'
# Printing the original string
print('Original string is : ', s)
# Result of calling capitalize() is made to reference by the reference of original string.
s = s.capitalize()
# Old reference variable pointing to the new string
print('String value after capitalize() method : ', s)
Original string value : you have got to live your life!
String value after capitalize() method : You have got to live your life!
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement