回答編集履歴

1

追記

2019/01/18 08:15

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -1,6 +1,6 @@
1
1
  ```Python
2
2
 
3
- print(*list, sep='')
3
+ print(*lst, sep='')
4
4
 
5
5
  ```
6
6
 
@@ -10,6 +10,40 @@
10
10
 
11
11
  ```Python
12
12
 
13
- print(''.join(list))
13
+ print(''.join(lst))
14
14
 
15
15
  ```
16
+
17
+
18
+
19
+ ---
20
+
21
+ 変数をlistと命名するのは厳に避けてください。
22
+
23
+ 分かりづらいエラーを引き起こします。
24
+
25
+ ```Python
26
+
27
+ >>> list('spam')
28
+
29
+ ['s', 'p', 'a', 'm']
30
+
31
+ >>>
32
+
33
+ >>> list = [1, 2, 3]
34
+
35
+ >>>
36
+
37
+ >>> list('spam')
38
+
39
+ Traceback (most recent call last):
40
+
41
+ File "<stdin>", line 1, in <module>
42
+
43
+ TypeError: 'list' object is not callable
44
+
45
+ ```
46
+
47
+
48
+
49
+ 同様につけてしまいがちな名前としては、`max` `id` `len` `str` などがあります。