有一个代码:
test0 = [ ]
test1 = ['a1','a2','a3','b1','b2','b3','c1','c2','c3']
while True:
p = str(input("Input: "))
test0.append(p)
if list(set(test0[-1]) & set(test1)):
print('True')
else:
print('False')
结论:
Input: a1
False
Input: teat
False
Input: c1
False
Input: wtf?
False
Input:
只要p值在test1字典中,代码就应该显示True,但我在某处犯了错误。在互联网上搜索答案,我找不到它。
你能告诉我我在哪里搞砸了。
这应该有效。
更好地命名你的变量。
结论: