【发布时间】:2015-01-24 10:36:49
【问题描述】:
我有两个列表要比较并打印出两者的共同点
things=['Apple', 'Orange', 'Cherry','banana','dog','door','Chair']
otherThings=['Apple', 'Orange','TV' ,'Cherry','banana','Cat','Pen','Computer','Book']
if (things == otherThings): # this condtion will not work
print "%s\t%s" % (things, otherThings)
else:
print "None"
问题:在这种情况下我应该使用什么合适的条件?
预期结果:['Apple', 'Orange','Cherry','banana']
【问题讨论】:
-
你处理的是
List而不是字典!!! -
我应该解决这个问题 (._.)""
标签: python list dictionary conditional