回答編集履歴

2

修正

2020/07/27 08:33

投稿

can110
can110

スコア38286

test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- words = ['mother', 'furure', 'dream', 'food']
9
+ words = ['mother', 'future', 'dream', 'food']
10
10
 
11
11
  ws = '|'.join(words)
12
12
 

1

コード修正

2020/07/27 08:33

投稿

can110
can110

スコア38286

test CHANGED
@@ -10,23 +10,17 @@
10
10
 
11
11
  ws = '|'.join(words)
12
12
 
13
- r = re.compile( f'[{ws}]*')
13
+ r = re.compile( f'({ws})+')
14
14
 
15
-
16
-
17
- for s in ['', ' ', 'mother', 'foodfood', 'motherfood', 'abc']:
15
+ for s in ['', ' ', 'mother', 'foodfood', 'motherfood', 'abc', 'doof']:
18
16
 
19
17
  print(f'[{s}]', end=':')
20
18
 
21
19
  print('yes' if r.fullmatch(s) else 'no')
22
20
 
23
- # ''を許したくない場合は len(s) > 0と組み合わせ判定すればよい
24
-
25
-
26
-
27
21
  """
28
22
 
29
- []:yes
23
+ []:no
30
24
 
31
25
  [ ]:no
32
26
 
@@ -38,6 +32,8 @@
38
32
 
39
33
  [abc]:no
40
34
 
35
+ [doof]:no
36
+
41
37
  """
42
38
 
43
39
  ```