title: Detect numbers between letters in a string python
body: <p>I write a code to verify the license plates of cars and there are some conditions to achieve this purpose:</p>
  <ul>
  <li>The first letter should not be <code>0</code></li>
  <li>It shouldn't have any numbers between letters(<code>AAA12</code> is ok, but <code>AA2AAA</code> is not.)</li>
  <li>It should start with two letters</li>
  <li>The count of letters must be between 2 - 6 letters</li>
  </ul>
  <pre class="lang-py prettyprint-override"><code>def is_valid(s):
      s = s.lower()
      if len(s) &gt;= 2 and len(s) &lt;= 6 and s[0] != 0 and s[0:2].isalpha():
          if s.isalpha():
              return True
          elif s.isalnum():
              for sq in s.split():
                  for w in sq:
                      if w.isdigit():
                          x = sq.index(w)
                          try:
                              if s[w:].isalpha():
                                  return False
                              else:
                                  return True
      
                          except:
                              return True
  </code></pre>
  <p>So my code is doing most of these conditions in a right way, but when I enter e.g. <code>HL23P2</code>, I expect to get <code>False</code> but it returns <code>True</code>.</p>
  <p>Why does it return <code>False</code>? because I can't have numbers between letters only it is allowed when its like e.g. <code>HEL23</code>.</p>
  <p>But how can I detect numbers between letters?</p>