Python detect character surrounded by spaces
<p>Anyone know how I can find the character in the center that is surrounded by spaces?</p>

<p><code>1 + 1</code></p>

<p>I'd like to be able to separate the <code>+</code> in the middle to use in a if/else statement.</p>

<p>Sorry if I'm not too clear, I'm a Python beginner.</p>

<p>You can use regex:</p>

<pre><code>s="1 + 1"
a=re.compile(r' (?P&lt;sym&gt;.) ')
a.search(s).group('sym')
</code></pre>

python python-3.x