title: When to use ast.literal_eval
body: <p>I came across this code and it works, but I am not entirely sure about <strong>when to use ast</strong> and <strong>whether there are performance issues</strong> when this is used instead of getting the string value from <code>input()</code> and converting it to int. </p>
  
  <pre><code>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
  </code></pre>
  
  <p>I read the docs I understand what it does. </p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>I am looking for an explanation on above bold points.</p>