The char.title(()
function in Python is used to return an element-wise titled cased version of an input array of strings or Unicode.
char.title(a)
The char.title(()
function takes a single parameter value, a
, which represents the input array of strings or Unicode.
The char.title(()
function returns an array of strings or Unicode, depending on the input type passed to the function.
Let’s look at the code below:
import numpy as np# creating an arraymyarray1 = np.array(["ThIS", "IS", "ThE", "Title", "OF", "this", 'coDE'])# implementing the char.title() functionprint(np.char.title(myarray1))# creating another arraymyarray2 = np.array(["THIS IS the TitlE of this code"])# implementing the char.title() functionprint(np.char.title(myarray2))
NumPy
module.mystring1
and mystring2
using the array()
function.char.title()
function on both input arrays, myarray1
and myarray2
, and print the results to the console.