search

Home  >  Q&A  >  body text

list - 初学python,出现错误,但是不知道如何修改

           初学python,出现错误,但是不知道如何修改

错误提示是
Traceback:
in
in openOrSenior
AttributeError: 'list' object attribute 'append' is read-only

def openOrSenior(data):
    # Hmmm.. Where to start?
    long=len(data)
    result=[]
    for i in range(long):
        if (data[i][0]>=55) and (data[i][1]>7):
            result.append=("Senior")
        else:
            result.append=("Open")
          
    return result
怪我咯怪我咯2804 days ago1555

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-04-18 10:07:36

    result.append('Senior'), no equal sign required

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 10:07:36

    There is an extra equal sign after result.append

    reply
    0
  • Cancelreply