fork download
  1. fake_data = [('note name 1', 5, '11/21/13'), ('note name 2', 3, '11/22/13'), ('note name 1', 1, '11/24/13')]
  2. the_dict = {}
  3.  
  4. for item in fake_data: # for each note
  5. if item[0] in the_dict: #do we already have an entry in our dictionary for this note name?
  6. the_dict[item[0]].append(item) #we do, add this new occurence onto our list of notes
  7. else:
  8. the_dict[item[0]] = [item] #we don't have anything in our dict for this note, so start a new list
  9.  
  10. print(len(the_dict['note name 1']))
Success #stdin #stdout 0.01s 7896KB
stdin
Standard input is empty
stdout
2