title: create simple dictionary in python
body: <blockquote>
    <p>person1    wine2</p>
    
    <p>person1    wine1</p>
    
    <p>person2    wine1</p>
    
    <p>person2    wine2</p>
    
    <p>person2    wine3</p>
    
    <p>person2    wine4</p>
    
    <p>person2    wine5</p>
  </blockquote>
  
  <p>The above is my input in a separate text file. I want to create the following output dictionary in Python: </p>
  
  <blockquote>
    <p>output = {'wine1': ['person1', 'person2'], 'wine2':['person1','person2'], 'wine3':['person2'], 'wine4':['person2'], 'wine5':['person2'] }</p>
  </blockquote>
  
  <p>How do I create this output?</p>
  
  <p>I'm doing something wrong: </p>
  
  <pre><code>def read(text): 
      wine_wishes = dict() 
      final_assignments = dict()
      with open(text) as infile:
          for line in infile: 
              line = line.split() 
              try: 
                  wine_wishes[line[1]]
              except: 
                  wine_wishes[line[1]] = [line[0]]
  </code></pre>
  
  <p>As a result I get the incorrect output: {'wine4': ['person2'], 'wine5': ['person2'], 'wine1': ['person1'], 'wine2': ['person1'], 'wine3': ['person2']}</p>