In Python, the char.strip()
function returns an array where the input array’s leading character(s) is removed.
char.split(a, char)
This function takes the following parameter values:
a
: This is the input array of strings or Unicode.char
: This is the character(s) to be removed.This function returns an output array of strings or Unicode, depending on the input type passed to the function.
import numpy as np# creating an arraymyarray = np.array(["That", "There", "These", "They"])# implementing the char.strip() function to remove `Th`print(np.char.strip(myarray, "Th"))
numpy
module.array()
function to create an array called myarray
."Th"
, from each of the elements of the array to implement the char.strip()
function on the myarray
. Next, we print the result to the console.