Clarifying simple function
<p>The goodness of a string follows these two rules:</p>

<ul>
<li>The goodness of a string containing one or more 'u's is 0</li>
<li>otherwise, the goodness of a string is equal to the number of 'g's in the string</li>
</ul>

<p>"gbbgb" is 2<br>
"gubgb" is 0</p>

<pre><code>#I understand this function
def goodness(s):
    if s.count('u') &gt; 0:
       return 0 
    else:
       return s.count('g') 

#But not this one.
def best_slice(s, k):
    ''' s is str, k is an integer such that 0 &lt;= k &lt;= len(s). Return the starting index of the length-k slice of s with highest goodness. If k is zero, return -1.'''
    stop = len(s) - k  # ?
    best_start = -1 # ?
    best_goodness = 0  
    for i in range(stop + 1):
       cur_slice = s[i:i+k]
       slice_goodness = goodness(cur_slice)
       if slice_goodness &gt; best_goodness:
          best_start = i
          best_goodness = slice_goodness
    return best_start
</code></pre>

<p>Can someone please explain this for me, I do not understand it.</p>
