0
我想結合以下兩個列表,但組合1a除外。python中既沒有也沒有聲明
a=[1,2,3,4,5,6,7,8,9]
b=['a', 'b', 'c','d', 'e','f','g']
c=[]
for i in a:
for j in b:
if i is not 1 and j is not'a':
c.append(str(i) + j)
print c
這排除了1和'a'的所有組合。我怎樣才能排除1a
決不比較整數或'is'浮動。使用'=='和'!='。 –
布爾代數101,德摩根定律。 – njzk2