说集合之前,我们先说一个小例子,假设某公司有五个人喜欢打篮球,五个人喜欢打游戏,问即打游戏有打篮球 的人都有哪些? play_basketball = ['a','b','c','d','e'] play_game = ['a','b','c','f','g'] both_play=[] for name in play_basketball: if name in play_game: both_play.append(name) print(both_play) 结果: ['a', 'b',…