title: Mutating strings in python
body: <p>My brain cannot comprehend why this isn't working. I'm not very experienced and just trying to practice loops.</p>
  
  <p>I'm trying to create a function that takes a string (currently one word) and capitalizes letters at random. With this code python throws a TypeError: list indices must be integers or slices, not strings</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>import random
  
  list = []
  
  def hippycase(string):
      for letter in string:
          list.append(letter)
  
      for index in list:
          if random.randint(1,2) == 1:
              list[index] = list[index].upper()
          else:
              list[index] = list[index].lower()
      return list
  
  
  print(hippycase("pineapple"))
  </code></pre>
  
  <p>Any ideas or tips? Thanks</p>
  
  <p>EDIT: Since this has been marked as a duplicate as someone thinks is at the following link, I'll try and clear up what is different:
  <a href="https://stackoverflow.com/questions/522563/accessing-the-index-in-python-for-loops">Accessing the index in Python &#39;for&#39; loops</a>
  I'm not trying to actively seek the index, I'm just practicing for loops which coincidentally goes through the index of the iterable sequentially. I also think if a fellow noob coder is searching this might be more helpful. </p>