Pandatron03 0 Newbie Poster

Hiya, looking for some help on this bit of code:

def save(x,y,z):
        user=x
        yourinventory=y
        score=z
        allinvent=[]
        allscore=[]
        with open("Inventory.txt","r+")as inventory:
            for line in inventory:
                allinvent.append(line.strip().split(','))
                allinvent.append("\n")
            for line in allinvent:
                if (line[0]==yourinventory):
                    allinvent.append(yourinventory)
                    allinvent.pop(line[0:8])
                    print(allinvent)
                    break
            inventory.append(allinvent)
            inventory.close

I'm currently working on saving things like inventory, and I'm not sure what I need to use instead of append as I keep getting this error.

Traceback (most recent call last):
  File "\\file1\Student-homes\Intake15\15QuintonSA\My Documents\Year 10\Computer Science\.Adventure Quest v2\main file.py", line 192, in <module>
    save("pandatron03", invent, 8)
  File "\\file1\Student-homes\Intake15\15QuintonSA\My Documents\Year 10\Computer Science\.Adventure Quest v2\main file.py", line 19, in save
    inventory.append(allinvent)

AttributeError: '_io.TextIOWrapper' object has no attribute 'append'

Help is appreciated, as I'm struggling to find a source I am able to understand for this context.

  • (It's a school project for some background context.)*