human
Find the word from a given sentence having given word as prefix | Function to find the position of the string having word as prefix.
Initialize an List.
Extract words from the sentence.
Traverse each word.
Traverse the characters of word.
If prefix does not match.
Otherwise.
Return the word.
Return - 1 if not present.
Driver code"
How can the above be solved in Python?
 ... Write me a code to find the word from a given sentence having given word as prefix and the other steps required?
assistant
#Here is code to find the word from a given sentence having given word as prefix and the other steps required.
 def isPrefixOfWord ( sentence , word ) :
	a = sentence . split ( " ▁ " )
	v = [ ]
	for i in a :
		v . append ( i )
	for i in range ( len ( v ) ) :
		for j in range ( len ( v [ i ] ) ) :
			if ( v [ i ] [ j ] != word [ j ] ) :
				break
			elif ( j == len ( word ) - 1 ) :
				return v [ i ]
	return - 1
s = " Welcome ▁ to ▁ Geeksforgeeks "
word = " Gee "
print ( isPrefixOfWord ( s , word ) )