#C11041. Identifier Validator
Identifier Validator
Identifier Validator
You are required to implement a function that checks if a given string is a valid identifier in a programming language. A valid identifier must obey the following rules:
- The identifier must start with a letter (a-z, A-Z) or an underscore (_). It cannot start with a digit or any other special character.
- The remaining characters (if any) must be alphanumeric (a-z, A-Z, 0-9) or underscores (_).
- The identifier must not be one of the reserved keywords. For the purposes of this problem, the reserved keywords are given by the following list: \( \texttt{if, else, while, for, return, break, continue, def, class, try, except, import, from, as, with} \)
- An empty string is not considered a valid identifier.
You need to read a single string from standard input and print True
if the string is a valid identifier according to the above rules, or False
otherwise. Note that the output should be printed to standard output.
inputFormat
The input consists of a single line containing the string to be checked as an identifier. The string may include letters, digits, underscores, or other special characters.
outputFormat
Output a single line: True
if the string is a valid identifier or False
otherwise.
variable
True