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

回答編集履歴

2

修正

2018/05/22 12:47

投稿

LouiS0616
LouiS0616

スコア35678

answer CHANGED
@@ -1,16 +1,22 @@
1
+ range(a)を分解して受け取れないのは、hayataka2049さんがご指摘されているとおりです。
2
+
3
+ ---
1
- zipはイテラブルに対して使います。
4
+ また、zipはイテラブルに対して使います。
2
5
  単に値のセットを作りたいなら、タプルやリストとして扱えば良いです。
3
6
  ```Python
7
+ >>> i = 4
8
+ >>> j = 2
9
+ >>> zip(i, j)
4
- a,b = map(int,input().split())
10
+ Traceback (most recent call last):
11
+ File "<stdin>", line 1, in <module>
12
+ TypeError: zip argument #1 must support iteration
13
+ >>>
14
+ >>> (i, j)
5
- x = []
15
+ (4, 2)
6
- for _ in range(a):
7
- i,j = map(int,input().split())
8
- y = (i,j)
9
- x.append(y)
10
16
  ```
11
17
 
12
- range(a)を分解して受け取れないのは、hayataka2049さんがご指摘されているとおりです。
13
18
 
19
+
14
20
  ---
15
21
  慣れるまでは真似っこで良いんじゃないでしょうか。
16
22
  [Qiita - Pythonで競プロやるときによく書くコードをまとめてみた](https://qiita.com/y-tsutsu/items/aa7e8e809d6ac167d6a1)

1

修正

2018/05/22 12:47

投稿

LouiS0616
LouiS0616

スコア35678

answer CHANGED
@@ -3,8 +3,14 @@
3
3
  ```Python
4
4
  a,b = map(int,input().split())
5
5
  x = []
6
- for i,j in range(a):
6
+ for _ in range(a):
7
7
  i,j = map(int,input().split())
8
8
  y = (i,j)
9
9
  x.append(y)
10
- ```
10
+ ```
11
+
12
+ range(a)を分解して受け取れないのは、hayataka2049さんがご指摘されているとおりです。
13
+
14
+ ---
15
+ 慣れるまでは真似っこで良いんじゃないでしょうか。
16
+ [Qiita - Pythonで競プロやるときによく書くコードをまとめてみた](https://qiita.com/y-tsutsu/items/aa7e8e809d6ac167d6a1)