fork download
  1. #! python3
  2.  
  3. data = [
  4. ['spanish', 'web2.0', 'e-learning', 'education', 'social', 'spain', 'tools', 'learning', 'google', 'e-learning2.0'],
  5. ['education', 'technology', 'learning', 'classroom', '%22educational%20technology%22', 'google', 'teaching', 'collaboration', 'students', 'web2.0'],
  6. ['education'],
  7. ['technology']
  8. ]
  9.  
  10. search_table = {}
  11.  
  12. for i, tag_list in enumerate(data):
  13. for tag in tag_list:
  14. if tag not in search_table:
  15. search_table[tag] = set()
  16. search_table[tag].add(i)
  17.  
  18. # How many people have `technology`?
  19. print(len(search_table["technology"]))
  20.  
  21. # How many people have both `technology`, `education`?
  22. print(len(search_table["technology"] & search_table["education"]))
  23.  
Success #stdin #stdout 0.02s 9944KB
stdin
Standard input is empty
stdout
2
1