title: Is there a better, pythonic way to do this?
body: <p>This is my first python program - </p>
  
  <p>Requirement: Read a file consisting of {adId UserId} in each line. For each adId, print the number of unique userIds.</p>
  
  <p>Here is my code, put together from reading the python docs. Could you give me feedback on how I can write this in more python-ish way?</p>
  
  <p>CODE :</p>
  
  <pre><code>import csv
  
  adDict = {}
  reader = csv.reader(open("some.csv"), delimiter=' ')
  for row in reader:
      adId = row[0]
      userId = row[1]
      if ( adId in adDict ):
          adDict[adId].add(userId)
      else:
          adDict[adId] = set(userId)
  
  for key, value in adDict.items():
      print (key, ',' , len(value))
  </code></pre>
  
  <p>Thanks.</p>