質問編集履歴
2
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,23 @@
|
|
22
22
|
|
23
23
|
一部抜き出しですが、上のコードに対して```NameError: name 'nums' is not defined```
|
24
24
|
|
25
|
-
というエラーが出ます。
|
25
|
+
というエラーが出ます。(正確には
|
26
|
+
|
27
|
+
```
|
28
|
+
|
29
|
+
Traceback (most recent call last):
|
30
|
+
|
31
|
+
File "Main.py", line 51, in <module>
|
32
|
+
|
33
|
+
othello.putcells()
|
34
|
+
|
35
|
+
File "Main.py", line 18, in putcells
|
36
|
+
|
37
|
+
for i in nums:
|
38
|
+
|
39
|
+
NameError: name 'nums' is not defined
|
40
|
+
|
41
|
+
```)
|
26
42
|
|
27
43
|
numsはclassの直下に置いたのでクラス内のすべての関数内で使えるクラス変数になっていると思ったのですが...
|
28
44
|
|
1
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,14 +1,22 @@
|
|
1
1
|
```
|
2
2
|
|
3
|
-
class Othello:
|
3
|
+
class Othello():
|
4
4
|
|
5
|
+
n = int(input())
|
6
|
+
|
7
|
+
nums = [input().split() for i in range(n)]
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
def putcells(self):
|
12
|
+
|
5
|
-
nums
|
13
|
+
for i in nums:
|
6
14
|
|
7
15
|
|
8
16
|
|
9
|
-
|
17
|
+
othello = Othello()
|
10
18
|
|
11
|
-
|
19
|
+
othello.putcells()
|
12
20
|
|
13
21
|
```
|
14
22
|
|