可能重复:
从Python中的两个列表中获得差异
这样做的简化方法是什么?我一直在努力,我无法弄清楚.列出a和列表b,新列表应该包含仅在列表a中的项目.所以:
a = apple, carrot, lemon
b = pineapple, apple, tomato
new_list = carrot, lemon
Run Code Online (Sandbox Code Playgroud)
我尝试编写代码,但每次总是将整个列表返回给我.
hand = ['A','Q']
points = 0
player_cards1 = ['2']
value1 = 2
player_cards2 = ['3']
value2 = 3
player_cards3 = ['4']
value3 = 4
player_cards4 = ['5']
value4 = 5
player_cards5 = ['6']
value5 = 6
player_cards6 = ['7']
value6 = 7
player_cards7 = ['8']
value7 = 8
player_cards8 = ['9']
value8 = 9
player_cards9 = ['T']
value9 = 10
player_cards10 = ['Q']
value10 = 10
player_cards11 = ['K']
value11 = 10
player_cards12 = ['J']
value12 = 10
ACE11 = …Run Code Online (Sandbox Code Playgroud)