The char.startswith()
function in Python returns an array of Boolean values which is True
where the string element in an input array of string starts with prefix
. Otherwise, it returns False
.
char.startswith(a, prefix, start=0, end=None)
The char.startswith()
function takes the following parameter values:
a
: An input array of strings.prefix
: A string representing the prefix to be searched for.start
, end
: The optional start
means that the test will begin at that position while an optional end
means stopping the comparison at that position.The char.startswith()
function returns an array of Boolean values with the same shape as the input array a
.
import numpy as np# creating input arraysmyarray1 = np.array(["Theo","Theophilus","The","Theology"])# printing the input arrayprint(myarray1)# implementing the char.startswith()# function on both arrays to see if they are equalprint(np.char.startswith(myarray1,"Theo",start=0,end=None))