#C13520. Valid Python Variable Name
Valid Python Variable Name
Valid Python Variable Name
You are given a candidate string and your task is to determine whether it is a valid Python variable name. A variable name in Python must satisfy the following conditions:
- The name must not be empty.
- The first character must be a letter (a-z, A-Z) or an underscore (_).
- All subsequent characters must be letters, digits (0-9), or underscores (_).
- The name must not be a reserved Python keyword (e.g., \(\text{for}\), \(\text{while}\), \(\text{if}\), etc.).
You will read the candidate name from standard input and print Valid
if it meets all the criteria or Invalid
otherwise.
inputFormat
The input consists of a single line containing the candidate variable name. Note that the input may contain leading or trailing whitespace which should be ignored.
outputFormat
Output a single line: Valid
if the candidate is a valid Python variable name, otherwise output Invalid
.
variable
Valid