title: How to set a variable equal to an object inside a dictionary in python
body: <p>I am new to python and I'm trying to write a simple word counter using a dictionary.  I am wondering why the following code will not work:</p>
  
  <pre><code>while word != None:
        wordObject = Word()
        wordObject.setWord(word)
        if dictionary.has_key(wordObject.getWord():
              setCount = dictionary[wordObject.getWord()]
              setCount.setCount()
  </code></pre>
  
  <p>If I leave this as is it never enters the if statement, if I put a key value in the has key method then it will enter the statement and say that I have invalid syntax on my setCount variable.  I am trying to set that variable to the object stored at the key value in the dictionary I made and then increment the words count with the setCount method. Thanks.</p>