title: Capitalization of all characters string in a double loop in Python
body: <p>I have the following Python code, that cycles thru the string and capitalizes each character:</p>
  
  <pre><code>str = 'abcd'
  l  = list(str)
  for i in range(len(l)):
      rl = list(str)
      cap_char = l[i].capitalize()
      rl[i] = cap_char
      str1 = ''.join(rl)
      print str1
  </code></pre>
  
  <p>Which produces:</p>
  
  <blockquote>
    <p>Abcd aBcd abCd abcD</p>
  </blockquote>
  
  <p>I would like to enhance this code to increment number of successive characters subject to capitalization until such number reaches len(l) - 1 to produce:</p>
  
  <pre><code>Abcd aBcd abCd abcD    &gt;&gt; - 1 char capitalized
  ABcd aBCd abCD AbcD    &gt;&gt; - 2 chars capitalized
  ABCd aBCD AbCD ABcD    &gt;&gt; - 3 chars capitalized
  </code></pre>
  
  <p>I am running into "index out of range" errors when I do index arithmetic, understand idices should wrap, but can't seem to produce an elegant code ;(</p>