human
Give me a code to count words in a given string and the other steps required given the following:
Count words in a given string | Function to count total number of words in the string.
Check if the string is null or empty then return zero.
Converting the given string into a character array.
Check if the character is a letter and index of character array doesn 't  equal to end of line that means, it is  a word and set isWord by true.
Check if the character is not a letter that means there is a space , then we increment the wordCount by one and set the isWord by false.
Check for the last word of the sentence and increment the wordCount by one.
Return the total number of words in the string.
Given String str.
Print the result"
Solution in Python:
assistant
#Here is code to count words in a given string and the other steps required.
 def countWords ( Str ) :
	if ( Str == None or len ( Str ) == 0 ) :
		return 0
	wordCount = 0
	isWord = False
	endOfLine = len ( Str ) - 1
	ch = list ( Str )
	for i in range ( len ( ch ) ) :
		if ( ch [ i ] . isalpha ( ) and i != endOfLine ) :
			isWord = True
		elif ( not ch [ i ] . isalpha ( ) and isWord ) :
			wordCount += 1
			isWord = False
		elif ( ch [ i ] . isalpha ( ) and i == endOfLine ) :
			wordCount += 1
	return wordCount
Str =   " One two three
	four five   "
print ( " No ▁ of ▁ words ▁ : " , countWords ( Str ) )