title: Python TypeError: 'type' object does not support item assignment
body: <p>I have to design and implement a <code>TwoSum</code> class. It should support the following operations:</p>
  
  <ul>
  <li><code>add</code> - Add the number to an internal data structure.</li>
  <li><code>find</code> - Find if there exists any pair of numbers which sum is equal to the value.</li>
  </ul>
  
  <p>Here is my code:</p>
  
  <pre><code>class TwoSum(object):
  
      dict = {}
  
      def add(self,n):
          dict[n] = n #TypeError: 'type' object does not support item assignment
  
      def find(self,n):
          for i in range(0,len(dict)+1):
              if dict[i] == None:
                  continue
  
              val = n - dict[i]
              if dict[val] != None and val != i+1:
                  return True
          return False
  
  test = TwoSum()
  test.add(1)
  test.add(3)
  test.add(5)
  print(test.find(4))  # True
  print(test.find(7))  # False
  </code></pre>
  
  <p>I got error message </p>
  
  <blockquote>
    <p>TypeError: 'type' object does not support item assignment for "dict[n] = n"</p>
  </blockquote>
  
  <p>Any help or suggestion? Thank you so much!</p>