Python Indexing not returning expected value
<p>I am trying to return the value M from Mr. Smith but whenever I run my code below it returns ''</p>

<pre><code>&gt;&gt;&gt;name = input("Please input your name: ")
Please input your name: Mr. Smith 
&gt;&gt;&gt; if name == name.find(' ') and name.isalpha():
    get_initial = name[0]
&gt;&gt;&gt;get_initial
''
</code></pre>

<p>I see a lot of problems in this proposed code.</p>

<p>First of all, <code>input()</code> evaluates the input string as a python expression and that's not what you want, you need to use <code>raw_input()</code> instead.
Second, <code>isalpha()</code> won't return True if input includes '.' or spaces, so you need to find another metric, for example, if only alphabetical characters are allowed, you can use <code>isalpha()</code> this way:</p>

<pre><code>name_nospaces = "".join(name.split())
if name_nospaces.isalpha():
    ...
</code></pre>

<p>Then, it doesn't make much sense to do <code>name == name.find(' ')</code>, just have:</p>

<pre><code>if name.find(' '):
    ...
</code></pre>

python