title: A python solution of "count and say" from leetcode went wrong
body: <pre><code>class Solution:
      # @param n, an integer
      # @return a string
      def countAndSay(self, n):
          def f(string):
              a = []
              count_1 = 1
              count_2 = 1
              s = string[1:] + 'e'                                    #calculate i from string[1](this is to disregard the case of string[0]), meanwhile add 'e' to notify the end of the string
              for i, j in enumerate(s):
  
                  if j == '1':
                      if string[i] == '1':                            #check whether the last member in string is the same as j
                          count_1 += 1                                #if so, count_1 add 1, save for further list appending
                      else:
                          count_1 = 1                                 #reset the count if last character does not match with j
                          a.append[(str(count_2) + '2')]              
  
                  if j == '2':
                      if string[i] == '2':
                          count_2 += 1
                      else:
                          count_2 = 1
                          a.append[(str(count_1) + '1')]
  
                  if j == 'e':                                         #j=='e' if the iteration reach the end, and it is the right time for adding the final member of the expected list
                      if string[i] == '1':                            
                          a.append[(str(count_1) + '1')]
                      if string[i] == '2':
                          a.append[(str(count_2) + '2')]
  
                  return ''.join(list)
  
          def seq(n): 
              if n == 1:
                  return '1'
              if n == 2:
                  return '11'
              if n == 3:
                  return '21'
              else:
                  return f(seq(n-1))
  
          return seq(n)
  </code></pre>
  
  <p>This is a solution of a problem from leetcode:
  <a href="https://leetcode.com/problems/count-and-say/" rel="nofollow">https://leetcode.com/problems/count-and-say/</a></p>
  
  <p>It notifies me that:</p>
  
  <blockquote>
    <p>Runtime Error Message:    Line 17: TypeError:
    'builtin_function_or_method' object has no attribute '<strong>getitem</strong>'</p>
    
    <p>Last executed input:  4</p>
  </blockquote>
  
  <p>Line 17 comes as follows: </p>
  
  <pre><code>a.append[(str(count_2) + '2')]
  </code></pre>
  
  <p>Please, I am a completely novice and don't know how to solve this problem.
  Also, I would like you to improve my code as well. Thank you so much.</p>