Check if a string represents a hexadecimal number or not | Function to check if the string represents a hexadecimal number ; Iterate over string ; Check if the character is invalid ; Print true if all characters are valid ; Given string ; Function call
def checkHex ( s ) : NEW_LINE INDENT for ch in s : NEW_LINE INDENT if ( ( ch < '0' or ch > '9' ) and ( ch < ' A ' or ch > ' F ' ) ) : NEW_LINE INDENT print ( " No " ) NEW_LINE return NEW_LINE DEDENT DEDENT print ( " Yes " ) NEW_LINE DEDENT s = " BF57C " NEW_LINE checkHex ( s ) NEW_LINE