Replacing string in a list of strings
<p>I have problem with my code. In this example it should print out <code>The Wind in the Willows</code>, but it does print <strong>The Wind In The Willows</strong>. I think the problem is that replace function does not execute. I have no idea what's wrong with this code. Please help.</p>

<p>PS. Basic idea of this function is to return title lookalike string with exception (<code>minor_words</code>). <code>Minor_words</code> should be lower case in a title (despite the case if <code>minor_words</code> is the first word in the <code>title</code>)</p>

<pre><code>def title_case(title, minor_words):
    exc = [x for x in title.lower().split() if x in minor_words.lower().split()]
    for string in exc:
        if title.split().index(string) == 0:
            title = title.title()
        else:
            title = title.title().replace(string, string.lower())
    return title


print (title_case('THE WIND IN THE WILLOWS', 'The In'))
</code></pre>

<pre><code>for x in minor_words.split():
        title = title.replace(x,x.lower())
</code></pre>

<p>I'm a little confused as to what exactly you are trying to do(its late for me so I can't think) but that will replace all words in <code>title</code> that are <code>minor_words</code> with a lower case copy. Making the first word capital can be done with <code>title = title.title()[0]+title[1:]</code></p>

python string