回答編集履歴
1
追記
answer
CHANGED
@@ -7,4 +7,17 @@
|
|
7
7
|
if ‘ABC’ in s or ‘DE’ in s:
|
8
8
|
print(s)
|
9
9
|
|
10
|
+
```
|
11
|
+
|
12
|
+
ただし、これだとマッチングを取る候補を変更しにくいので、anyを使って次のようにもできます。
|
13
|
+
|
14
|
+
``` python
|
15
|
+
a = ['ABCD', 'ABD', 'BD', 'CDABCD', 'ADEBCA']
|
16
|
+
|
17
|
+
template = { 'ABC', 'DE'}
|
18
|
+
|
19
|
+
for s in a:
|
20
|
+
if any(t in s for t in template):
|
21
|
+
print(s)
|
22
|
+
|
10
23
|
```
|