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
def isLower ( c ) : NEW_LINE INDENT return ord ( c ) >= ord ( ' a ' ) and ord ( c ) <= ord ( ' z ' ) NEW_LINE DEDENT def isUpper ( c ) : NEW_LINE INDENT return ord ( c ) >= ord ( ' A ' ) and ord ( c ) <= ord ( ' Z ' ) NEW_LINE DEDENT def detectUppercaseUseUtil ( S ) : NEW_LINE INDENT N = len ( S ) NEW_LINE i = 0 NEW_LINE if ( isLower ( S [ 0 ] ) ) : NEW_LINE INDENT i = 1 NEW_LINE while ( S [ i ] and isLower ( S [ i ] ) ) : NEW_LINE INDENT i += 1 NEW_LINE DEDENT return True if ( i == N ) else False NEW_LINE DEDENT else : NEW_LINE INDENT i = 1 NEW_LINE while ( S [ i ] and isUpper ( S [ i ] ) ) : NEW_LINE INDENT i += 1 NEW_LINE DEDENT if ( i == N ) : NEW_LINE INDENT return True NEW_LINE DEDENT elif ( i > 1 ) : NEW_LINE INDENT return False NEW_LINE DEDENT while ( S [ i ] and isLower ( S [ i ] ) ) : NEW_LINE INDENT i += 1 NEW_LINE DEDENT return True if ( i == N ) else False NEW_LINE DEDENT DEDENT def detectUppercaseUse ( S ) : NEW_LINE INDENT check = detectUppercaseUseUtil ( S ) NEW_LINE if ( check ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT S = " GeeKs " NEW_LINE detectUppercaseUse ( S ) NEW_LINE DEDENT