When to use ast.literal_eval
Question: I came across this code and it works, but I am not entirely sure about **when
to use ast** and **whether there are performance issues** when this is used
instead of getting the string value from `input()` and converting it to int.

    
    
    import ast
    
    cyper_key = ast.literal_eval(input("Enter the key (a value between 0 and 25) : "))
    
    # this get the user input as an int to the variable cyper_key
    

I read the docs I understand what it does.

> This can be used for safely evaluating strings containing Python values from
> untrusted sources without the need to parse the values oneself. It is not
> capable of evaluating arbitrarily complex expressions, for example involving
> operators or indexing.

I am looking for an explanation on above bold points.


Answer: If it's going to be used as an `int`, then just use:

    
    
    cypher_key = int(input("Enter the key (a value between 0 and 25) : "))
    

Only use that if you expect the user to be entering `10e7` or something. If
you want to handle different bases, you can use `int(input(...), 0)` to
automatically divine the base. If it really is an integer value between 0 and
25, there's no reason to use `ast`.

