#K53622. Check Valid Python Variable Name

    ID: 29573 Type: Default 1000ms 256MiB

Check Valid Python Variable Name

Check Valid Python Variable Name

In this problem, you are given a string and you must determine whether it is a valid variable name in Python. A variable name is considered valid if it satisfies all of the following conditions:

  1. It only contains letters (a-z, A-Z), digits (0-9), and underscores (_).
  2. It starts with a letter (a-z, A-Z) or an underscore (_).
  3. It is not a reserved keyword in Python.

The conditions can be mathematically described as follows:

[ \text{For a string } s, \ s \text{ is valid if } s \neq "" \land s[0] \in {[a-zA-Z], _} \land \forall c \in s,\ c \in {[a-zA-Z0-9], _} \land s \notin K ]

where (K) is the set of Python keywords. Your task is to implement a solution that reads a string from standard input and prints either "True" if the string is a valid variable name or "False" otherwise.

inputFormat

The input consists of a single line containing the string to be evaluated.

outputFormat

Output a single line: 'True' if the given string is a valid Python variable name; otherwise, output 'False'.## sample

my_variable
True