title: How do I utilize the input() command to include ANSI escape color codes?
body: <p>I'm relatively new to Python. I'm trying to utilize the input() function to include ANSI color codes, and store the values to a dictionary. I've tried using the colorama library too but wanted to try using this approach.</p>
  <pre><code>red = '\x1b[91m'
  reset = '\x1b[0m'
  
  color = input()
  </code></pre>
  <p>The user then types in the input:  <code>red+'test'+reset</code> which should return <code>'\x1b[91mtest\x1b[0m'</code> and printing this input via <code>print(color)</code> should return the string 'test' that is colored red.</p>
  <p>The <code>input()</code> turns it into a string <code>&quot;red+'test'+rest&quot;</code> instead. I've also tried directly typing in the ANSI code but I get the string <code>&quot;\\x1b[91mtest\\x1b[0m&quot;</code> instead. Is there a way to format it so I can choose anywhere in the string to add colors? e.g. if I wanted this script to get inputs and function like:</p>
  <pre><code>&quot;The &quot;+yellow+&quot;sun&quot;+reset+&quot; is bright in the &quot;+blue+&quot;sky&quot;+reset+&quot; today.&quot;
  </code></pre>