teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

追記

2019/01/18 08:15

投稿

LouiS0616
LouiS0616

スコア35678

answer CHANGED
@@ -1,8 +1,25 @@
1
1
  ```Python
2
- print(*list, sep='')
2
+ print(*lst, sep='')
3
3
  ```
4
4
 
5
5
  あるいは
6
6
  ```Python
7
- print(''.join(list))
7
+ print(''.join(lst))
8
- ```
8
+ ```
9
+
10
+ ---
11
+ 変数をlistと命名するのは厳に避けてください。
12
+ 分かりづらいエラーを引き起こします。
13
+ ```Python
14
+ >>> list('spam')
15
+ ['s', 'p', 'a', 'm']
16
+ >>>
17
+ >>> list = [1, 2, 3]
18
+ >>>
19
+ >>> list('spam')
20
+ Traceback (most recent call last):
21
+ File "<stdin>", line 1, in <module>
22
+ TypeError: 'list' object is not callable
23
+ ```
24
+
25
+ 同様につけてしまいがちな名前としては、`max` `id` `len` `str` などがあります。