title: '__getitem__` attribute error on the test case of leet code 66. Plus One is difficult to pass
body: <p>I am not able to pass one test case on <a href="https://leetcode.com/problems/plus-one/submissions/" rel="nofollow noreferrer">leetcode 66. Plus One</a>, but I have no idea what wrong is on my program.</p>
  
  <p><strong>Accepted Case</strong></p>
  
  <pre><code>Your input
  [1,2,3]
  Output
  [1,2,4]
  Expected
  [1,2,4]
  </code></pre>
  
  <p><strong>Not Accepted Case</strong></p>
  
  <pre><code>input
  [9]
  expected output
  [1,0]
  </code></pre>
  
  <p><strong>Error Message</strong></p>
  
  <pre><code>TypeError: 'int' object has no attribute '__getitem__`
  Line 16 in plusOne(Solution.py)
  Line 41 in _driver(Solution.py)
  Line 53 in &lt;module&gt;(Solution.py)
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code>class Solution(object):
      def plusOne(self, digits):
          """
          :type digits: List[int]
          :rtype: List[int]
          """
          nums = []
          last_num = digits[len(digits)-1] + 1
  
          if len(str(last_num)) == 1:
              digits[len(digits)-1] = last_num
              return digits
  
          elif len(str(last_num))&gt;1:
              for i in range(len(str(last_num))-1):
                  nums.append(last_num[-(len(str(last_num)))+i])
              return digits[:len(digits)-1] + nums
  </code></pre>
  
  <p><strong>What I tried to do to make sure the error message</strong></p>
  
  <pre><code>i = 9876
  s = str(i)
  print(s[-1])
  # 6
  
  print(s[-3])
  # 8
  </code></pre>