title: Function that finds the zero-based index of the longest run in a string in Python
body: <p>I'm trying to write a function that finds the zero-based index of the longest run in a string. If there is more than one run with the same length, the code should return the index of the first one.</p>
  
  <pre><code>a=["a","b","b","c","c","c","d","d","d","d","c","c","c","b","b","a"]
  
  def longestrun(myList):
      result = None
      prev = None
      size = 0
      max_size = 0
  
  
      for i in myList:
          if i == prev:
              print (i)
              size += 1
              if size &gt; max_size:
                  print ('*******  '+ str(max_size))
                  max_size = size 
          else:
              size = 0
          prev = i
      print (max_size+1)    
      return max_size+1
  
  
  longestrun(a)
  </code></pre>
  
  <p>I did some research and found this code which I think could be used to find the longest run in my list, but I don't know how to use this to find the index of the first letter in the longest run. Can anyone help me or give me some advice on how to do this? Overall, the output when the program is run should produce the number 6 as the first 'd' is at index 6, and is the longest run.</p>
  
  <p>Please note I am a beginner so it would be appreciated if answers were kept as simple as possible, and explained.</p>