中級 › TypeError: missing 1 required positional argument: 'self' の原因と直し方 › パターン3
TypeError: missing 1 required positional argument: 'self' の原因と直し方
クラスのメソッドをインスタンスを介さずに呼び出したときに出るエラーです。
1 class Robot: 2 def move(self): 3 print("Moving") 4 5 ___________.move() ^
Traceback (most recent call last):
File "main.py", line 5, in <module>
Robot.move()
TypeError: Robot.move() missing 1 required positional argument: 'self'
空欄を埋めて実行を通す
括弧を付けてインスタンスを作ってからメソッドを呼び出す、という2段階を省略すると起きるミスです。
次の問題