title: Tensorflow - Retrieve each character in a string tensor
body: <p>I'm trying to retrieve the characters in a string tensor for character level prediction. The ground truths are words where each character has an id in dictionary. I have a tensor corresponding to the length of the string. </p>
  
  <p>Now, I have to get each character in the string tensor. After checking the related posts, a simple retrieval can be as follows. Example string is "This"</p>
  
  <pre><code>a= tf.constant("This",shape=[1])
  b=tf.string_split(a,delimiter="").values  #Sparse tensor has the values array which stores characters
  </code></pre>
  
  <p>Now I want to make a string with spaces in between the letters "This" i.e " T h i s ". I need spacing at the start and the end too. 
  How do I do this?</p>
  
  <p>I have tried to iterate through the characters like below</p>
  
  <pre><code>for i in xrange(b.dense_shape[1]): # b.dense_shape[1] has the length of string
          x=b.values[i]
  </code></pre>
  
  <p>But the loop expects an integer rather than a tensor. </p>
  
  <p>Any idea on how to do the above tasks? I couldn't find any documentation related to this (apart from the tf.string_split function). Any suggestions are welcome. Thanks</p>