实例没有成员

时间:2018-04-03 04:07:21

标签: instance member

也许我得到一些基本的困惑,但我似乎无法解决如何解决这个问题。

enter image description here

编译器给了我

Traceback (most recent call last): File "python", line 153, in <module> File "python", line 90, in finish File "python", line 25, in registered AttributeError: 'Marathon' object has no attribute 'runnerList'

这一切似乎都是同一个问题。当然,实例确实有成员。我不确定为什么它认为它没有。

class Marathon:

# Creator
# -------

runnersList = []
timesList = []

def __init__(self):
  """Set up this marathon without any runners."""

# Inspectors
# ----------

# These are called anytime.

def registered(self, runner):
  """Return True if runner has registered, otherwise False."""
  for item in self.runnerList:
    if item == runner:
      return True
  else:
    return False

0 个答案:

没有答案