class Othello(): n = int(input()) nums = [input().split() for i in range(n)] def putcells(self): for i in nums: othello = Othello() othello.putcells()
一部抜き出しですが、上のコードに対してNameError: name 'nums' is not defined
というエラーが出ます。(正確には
Traceback (most recent call last): File "Main.py", line 51, in <module> othello.putcells() File "Main.py", line 18, in putcells for i in nums: NameError: name 'nums' is not defined ```) numsはclassの直下に置いたのでクラス内のすべての関数内で使えるクラス変数になっていると思ったのですが... classを書いてみたのは初めてなので、非常に初歩的な問題ですが教えていただけると嬉しいです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/06 14:58
2019/03/06 14:59
2019/03/06 15:03