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

質問編集履歴

2

修正

2017/10/15 17:06

投稿

yoyoyo0205
yoyoyo0205

スコア20

title CHANGED
File without changes
body CHANGED
@@ -7,9 +7,9 @@
7
7
  ```
8
8
 
9
9
  File "~/count1.py", line 23, in <module>
10
- text.extend(i[len(["tags"])])
10
+ text.extend(len(i["tags"]))
11
11
 
12
- KeyError: 1
12
+ TypeError: 'int' object is not iterable
13
13
  ```
14
14
 
15
15
  ###該当のソースコード
@@ -35,20 +35,10 @@
35
35
 
36
36
  text = []
37
37
  for i in data:
38
- text.extend(i[len(["tags"])])
38
+ text.extend(len(i["tags"]))
39
39
 
40
40
  with codecs.open("number_of_tags.txt","a","utf-8") as nt:
41
41
  for txt in text:
42
42
  nt.writelines(txt+"\n")
43
43
 
44
- ```
45
-
46
- ###試したこと
47
- ```
48
- text.extend(i[len(["tags"])])
49
- の部分を、
50
- text.extend(len(i["tags"]))
51
- とすると、
52
- TypeError: 'int' object is not iterable
53
- とエラーがでます。
54
44
  ```

1

補足

2017/10/15 17:05

投稿

yoyoyo0205
yoyoyo0205

スコア20

title CHANGED
File without changes
body CHANGED
@@ -40,4 +40,15 @@
40
40
  with codecs.open("number_of_tags.txt","a","utf-8") as nt:
41
41
  for txt in text:
42
42
  nt.writelines(txt+"\n")
43
+
44
+ ```
45
+
46
+ ###試したこと
47
+ ```
48
+ text.extend(i[len(["tags"])])
49
+ の部分を、
50
+ text.extend(len(i["tags"]))
51
+ とすると、
52
+ TypeError: 'int' object is not iterable
53
+ とエラーがでます。
43
54
  ```