Easier way to check if a string contains only one type of letter in python
<p>I have a string <code>'829383&amp;&amp;*&amp;@&lt;&lt;&lt;&lt;&gt;&gt;&lt;&gt;GG'</code>. I want a way to measure if a string has only one type of letter. For example the string above would return True, because it only has two Gs, but this string, <code>'829383&amp;&amp;*&amp;@&lt;&lt;&lt;&lt;&gt;&gt;&lt;&gt;GGAa'</code> would not. I've been iteratively going through the string having made it into an array. I was hoping someone knew an easier way. </p>

<p>use <code>filter</code> with <code>str.isalpha</code> function to create a sublist containing only letters, then create a set. Final length must be one or your condition isn't met.</p>

<pre><code>v="829383&amp;&amp;&amp;@&lt;&lt;&lt;&lt;&gt;&gt;&lt;&gt;GG"

print(len(set(filter(str.isalpha,v)))==1)
</code></pre>

python string python-3.x