human
Check if uppercase characters in a string are used correctly or not | ''Function to check if the character c is in lowercase or not.
''Function to check if the character c is in uppercase or not.
''Utility function to check if uppercase characters are used correctly or not.
'' Length of string.
'' If the first character is in lowercase.
'' Otherwise.
'' Check if all characters  are in uppercase or not.
'' If all characters are  in uppercase.
'' Check if all characters except  the first are in lowercase.
''Function to check if uppercase characters are used correctly or not.
'' Stores whether the use of uppercase  characters are correct or not.
'' If correct.
'' Otherwise.
''Driver Code.
'' Given string.
'' Function call to check if use of  uppercase characters is correct or not"
How can the above be solved in Python?
assistant
#Here is code to check if uppercase characters in a string are used correctly or not and the other steps required.
 def isLower ( c ) :
	return ord ( c ) >= ord ( ' a ' ) and ord ( c ) <= ord ( ' z ' )
def isUpper ( c ) :
	return ord ( c ) >= ord ( ' A ' ) and ord ( c ) <= ord ( ' Z ' )
def detectUppercaseUseUtil ( S ) :
	N = len ( S )
	i = 0
	if ( isLower ( S [ 0 ] ) ) :
		i = 1
		while ( S [ i ] and isLower ( S [ i ] ) ) :
			i += 1
		return True if ( i == N ) else False
	else :
		i = 1
		while ( S [ i ] and isUpper ( S [ i ] ) ) :
			i += 1
		if ( i == N ) :
			return True
		elif ( i > 1 ) :
			return False
		while ( S [ i ] and isLower ( S [ i ] ) ) :
			i += 1
		return True if ( i == N ) else False
def detectUppercaseUse ( S ) :
	check = detectUppercaseUseUtil ( S )
	if ( check ) :
		print ( " Yes " )
	else :
		print ( " No " )
if __name__ == ' _ _ main _ _ ' :
	S = " GeeKs "
	detectUppercaseUse ( S )