fork(1) download
  1. teams = {
  2. 'away_team_1' : { '7of9', 'Janeway', 'Tuvok' },
  3. 'away_team_2' : { '7of9', "B'Elanna Torres", 'Kim' },
  4. 'away_team_3' : { '7of9', 'Janeway', 'Jean-Luc Picard' }
  5. }
  6.  
  7. for name, contents in teams.items():
  8. print("%s %s" % (name, contents))
  9.  
  10. team1 = teams['away_team_1']
  11. team2 = teams['away_team_2']
  12. print(team1)
  13. print(team2)
  14. print("::and::")
  15. print(team1 & team2)
  16. print(team1.intersection(team2))
  17. print("::or::")
  18. print(team1 | team2)
  19. print(team1.union(team2))
  20. print("::difference::")
  21. print(team1 - team2)
  22. print(team1.difference(team2))
Success #stdin #stdout 0s 23304KB
stdin
Standard input is empty
stdout
away_team_1 set(['Tuvok', '7of9', 'Janeway'])
away_team_2 set(["B'Elanna Torres", '7of9', 'Kim'])
away_team_3 set(['Jean-Luc Picard', '7of9', 'Janeway'])
set(['Tuvok', '7of9', 'Janeway'])
set(["B'Elanna Torres", '7of9', 'Kim'])
::and::
set(['7of9'])
set(['7of9'])
::or::
set(["B'Elanna Torres", 'Tuvok', '7of9', 'Janeway', 'Kim'])
set(["B'Elanna Torres", 'Tuvok', '7of9', 'Janeway', 'Kim'])
::difference::
set(['Janeway', 'Tuvok'])
set(['Janeway', 'Tuvok'])