Uncapitalizing first letter of a name
<p>To code a name like DeAnna you type:</p>

<pre><code>name = "de\aanna" 
</code></pre>

<p>and </p>

<pre><code>print(name.title())
</code></pre>

<p>In this code <code>\a</code> capitalizes a normally uncapitalized letter. What do you code to produce a name like <code>"George von Trapp"</code> where I want to uncapitalize a normally capitalized letter?</p>

<p>Why not just roll your own function for it?</p>

<pre><code> def capitalizeName(name):
     #split the name on spaces
     parts = name.split(" ")

     # define a list of words to not capitalize
     do_not_cap = ['von']

     # for each part of the name,
     # force the word to lowercase
     # then check if it is a word in our forbidden list
     # if it is not, then go ahead and capitalize it
     # this will leave words in that list in their uncapitalized state
     for i,p in enumerate(parts):
          parts[i] = p.lower()
          if p.lower() not in do_not_cap:
              parts[i] = p.title()

      # rejoin the parts of the word
      return " ".join(parts)
</code></pre>

<p>The point to the <code>do_not_cap</code> list is that allows you to further define parts you may not want to capitalize very easily.  For example, some names may have a "de" in it you may not want capitalized.</p>

<p>This is what it looks like with an example:</p>

<pre><code>name = "geOrge Von Trapp"
capitalizeName(name)
# "George von Trapp"
</code></pre>

python string python-3.x