description of the capitalize() method

Python capitalize() makes the first letter of the string uppercase, and the others lowercase

Python capitalize() method syntax and return value

str.capitalize()

Return value This method returns a capitalized string.

Examples

# The following example shows an example capitalize() method:

str1 = "hello world!"
print("str1.capitalize(): ", str1.capitalize())
# output: str1.capitalize(): Hello world!

str2 = "mySql"
print("str2.capitalize(): ", str2.capitalize())
# output: str2.capitalize(): Mysql

 

Younes Derfoufi my-courses.net

2 thoughts on “The capitalize() string method in python”
  1. […] 1. capitalize ():   capitalize the first letter of the string 2. center (width, fill):   returns a string filled with spaces with the original string centered on the total width columns. 3. counts (str, beg = 0, end = len (string)):   counts the number of times str occurs in a string or a substring if the start of the start index and the end of the end index are indicated. 4. decode (encoding = 'UTF-8', errors = 'strict'):   decodes the string using the codec recorded for encoding. The default encoding is the default string encoding. 5. encode (encoding = 'UTF-8', errors = 'strict'):   returns the encoded version of the string; in case of error, the default value is to generate a ValueError value unless errors are indicated with "ignore" or "replace". 6. endswith (suffix, start = 0, end = len (string)):   determines whether a string or a substring string (if end indexes start and end indexes are indicated) ends with a suffix; returns true if yes and false otherwise. […]

  2. […] 1. capitalize ():   capitalize the first letter of the string 2. center (width, fill):   returns a string filled with spaces with the original string centered on the total width columns. 3. counts (str, beg = 0, end = len (string)):   counts the number of times str occurs in a string or a substring if the start of the start index and the end of the end index are indicated. 4. decode (encoding = 'UTF-8', errors = 'strict'):   decodes the string using the codec recorded for encoding. The default encoding is the default string encoding. 5. encode (encoding = 'UTF-8', errors = 'strict'):   returns the encoded version of the string; in case of error, the default value is to generate a ValueError value unless errors are indicated with "ignore" or "replace". 6. endswith (suffix, start = 0, end = len (string)):   determines whether a string or a substring string (if end indexes start and end indexes are indicated) ends with a suffix; returns true if yes and false otherwise. […]

Leave a Reply