title: Another capitalise every odd char of the string solution
body: <p>I just started studying Python and created some kind of task for myself that I'm struggling to solve...</p>
  
  <p>So, I'm on chapter on working with strings (accessing strings by index, changing etc).</p>
  
  <p>My task is - capitalize every odd char of the string. I saw the solution here: <a href="https://stackoverflow.com/questions/17865563/capitalise-every-other-letter-in-a-string-in-python">Capitalise every other letter in a string in Python?</a> </p>
  
  <p>but I don't like it... wanted to solve this by slices. So what I produced is followig code:</p>
  
  <pre><code>T = 'somesampletexthere'  
  R=""
  
  for i in range(0, len(T[1::2])):
          R+=T[::2][i].upper()+T[1::2][i].lower()
  
  print R
  </code></pre>
  
  <p>This code works great when there are even number of chars, for example with TESTTEXT but when the number is odd like here in EXAMPLE it will skipp last char (in this case E)</p>
  
  <p>This is because the range is till <code>len(T[1::2]))</code> (length of even characters) but if I'll try the length of odd characters <code>len(T[::2]))</code> I'll get error:</p>
  
  <pre><code>IndexError: string index out of range
  </code></pre>
  
  <p>logically because number of odd chars will always be bigger on 1 (in case of text with odd number of characters).</p>
  
  <p>So, my question is - how can I supress the error? So Python just return null or something in case the index is out of range of the given string?</p>
  
  <p>Or any other solutions of the task using slices?</p>