Capitalizing hyphenated name
<p>I have a script looking like this:</p>

<pre><code>firstn = input('Please enter your first name: ') 
lastn = input('Please enter Your last name: ') 
print('Good day, ' + str.capitalize(firstn) + ' ' + str.capitalize(lastn)+ '!')
</code></pre>

<p>It will work nicely with simple names like jack black or morgan meeman but when I input hyphenated name like <code>jordan-bellfort image</code> then I'd expect <code>"Jordan-Bellfort Image"</code> but I receive <code>"Jordan-bellfort Image"</code>.</p>

<p>How can I get python to capitalize the character right after hyphen?</p>

<p>You can use <a href="https://docs.python.org/2/library/stdtypes.html#str.title" rel="nofollow">title()</a>:</p>

<pre><code>print('Good day,', firstn.title(), lastn.title(), '!')
</code></pre>

<p>Example from the console:</p>

<pre><code>&gt;&gt;&gt; 'jordan-bellfort image'.title()
'Jordan-Bellfort Image'
</code></pre>

python capitalize