The char.capitalize()
function in Python is used to convert only the first character of each element of an input array of string to uppercase.
char.capitalize(a)
The char.capitalize()
function takes a single and mandatory parameter value a
, which represents the input array of strings that need to be capitalized.
The char.capitalize()
function returns an array of strings or Unicode, depending on the input types.
import numpy as np# creating an arraymyarray = np.array(["hello", "theophilus ,", 'HOW', "are", "you today?"])# implementing the char.capitalize() functionprint(np.char.capitalize(myarray))
numpy
module.myarray
, using the array()
function.char.capitalize()
function on the array myarray
and print the result to the console.