title: Dict order in python
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1867861/python-dictionary-keep-keys-values-in-same-order-as-declared">Python dictionary, keep keys/values in same order as declared</a>  </p>
  </blockquote>
  
  
  
  <p>Good day to all.
  I'm working on a sentiment analysis application in python (to which I am new) and I am experiencing a problem.
  I'm using the bag of words feature extractor but I'm experiencing one major problem when the bag of words function is called.
  Let's assume that we have the following text: "He will be the winner."
  When I call my function which has the following code: <code>dict([(word, True) for word in words])</code> I get the following result: </p>
  
  <blockquote>
    <p>{'will': True, 'be': True, 'the': True, 'winner': True, 'He': True}</p>
  </blockquote>
  
  <p>Which is OK except for the fact that the word ordering is off.
  If I use a loop like that one: </p>
  
  <pre><code>for i in range(0, len(words)):
  </code></pre>
  
  <p>The order of the output is OK but I don't know how I can create a dictionary out of that.
  So can anyone suggest a way to get my bag of words without messing up the ordering of the words?</p>
  
  <p>Thank you for your time and help.</p>
  
  <p>Teo</p>