title: How do you use a variable as an index when slicing strings in Python?
body: <p>I've been trying to slice two characters out of a string using a loop, but instead of grabbing two characters, it only grabs one.</p>
  
  <p>I've tried:</p>
  
  <pre><code>input[i:i+1]
  </code></pre>
  
  <p>and</p>
  
  <pre><code>input[i:(i+1)]
  </code></pre>
  
  <p>but neither seems to work.</p>
  
  <p>How do I use a variable for slicing?</p>
  
  <p>The full routine:</p>
  
  <pre><code>def StringTo2ByteList(input):
      # converts data string to a byte list, written for ascii input only
      rlist = []
      for i in range(0, len(input), 2):
          rlist.append(input[i:(i+1)])
      return rlist
  </code></pre>