title: Python: How to find all ways to decode a string?
body: <p>I'm trying to solve this problem but it fails with input &quot;226&quot;.</p>
  <p><strong>Problem</strong>:
  A message containing letters from A-Z is being encoded to numbers using the following mapping:</p>
  <pre><code>'A' -&gt; 1
  'B' -&gt; 2
  ...
  'Z' -&gt; 26
  </code></pre>
  <p>Given a non-empty string containing only digits, determine the total number of ways to decode it.</p>
  <p><strong>My Code:</strong></p>
  <pre><code>class Solution:
      def numDecodings(self, s: str) -&gt; int:
          decode =[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]
          ways = []
          for d in decode:
              for i in s:
                  if str(d) == s or str(d) in s:
                      ways.append(d)
                  if int(i) in decode:
                      ways.append(str(i))
          return len(ways)
  </code></pre>
  <p>My code returns 2. It only takes care of combinations (22,6) and (2,26).</p>
  <p>It should be returning 3, so I'm not sure how to take care of the (2,2,6) combination.</p>