title: Python looping through string and matching it with with wildcard pattern
body: <pre><code>string1="abc"
  string2="abdabcdfg"
  </code></pre>
  
  <p>I want to find if string1 is substring of string2. However, there are wildcard characters like <code>"."</code> can be any letter, <code>y</code> can be <code>"a"</code> or <code>"d"</code>, <code>x</code> can be <code>"b"</code> or <code>"c"</code>.
  as a result, <code>".yx"</code> will be substring of <code>string2</code>.</p>
  
  <p>How can I code it using only one loop? I want to loop through string2 and make comparisons at each index. i tried dictionary but I wand to use loop
  my code:</p>
  
  <pre><code>def wildcard(string,substring):
      sum=""
      table={'A': '.', 'C': '.', 'G': '.', 'T': '.','A': 'x', 'T': 'x', 'C': 'y', 'G': 'y'}
      for c in strand:
          if (c in table) and table[c] not in sum:
              sum+=table[c]
          elif c not in table:
              sum+=c
      if sum==substring:
          return True
      else:
          return False
  
  print wildcard("TTAGTTA","xyT.")#should be true
  </code></pre>