#K58607. Valid Identifier Checker
Valid Identifier Checker
Valid Identifier Checker
You are given a string. Your task is to determine whether the string is a valid identifier.
A string is considered a valid identifier if it meets the following conditions:
- The string is non-empty.
- The first character is either a letter (a-z or A-Z) or an underscore ('_').
- Every character in the string is either a letter, a digit (0-9), or an underscore.
For example:
variable_name_1
is valid._startWithUnderscore
is valid.1_startWithNumber
is not valid because it starts with a digit.variable-name
is not valid because of the hyphen.
Your program should read the input from standard input and output either True
or False
to standard output.
inputFormat
The input consists of a single line containing a non-empty string which may include letters, digits, underscores, or other characters.
Note: The string may be empty, in which case it should be considered invalid.
outputFormat
Output a single line: True
if the input string is a valid identifier according to the rules given above, otherwise output False
.
variable_name_1
True