所以可以说我有这样的如何检查是否只有指定的元素保留在列表中?
color = ['blue', 'green', 'red', 'white', 'hurley', 'maladroit']
名单我想在这里做的是检测时列表中“色”只包括那些没有颜色的是元素的“赫利”和“笨拙” 。
因此,像:
#If the list color has at least one color in it (E.g)color = ['blue','white','maladroit']
print('Nothing to see here')
#If the list only consists of elements that aren't colors
#(E.g)color = ['hurley','maladroit']
print("I don't see colors.... I actually legit don't...")
列出颜色并对其进行过滤。 –
https://www.tcl.tk/man/tcl8.4/TkCmd/colors.htm –
哦,不,这些颜色只是我用于此代码的示例,如果这是误导性的,则很抱歉。我会研究过滤方法,谢谢。 –