[Python] TypeError: descriptor 'append' for 'list' objects doesn't apply to a 'str' object....

Discussão em 'Python' iniciado por Stack, Julho 8, 2025.

  1. Stack

    Stack Membro Participativo

    this is my first time trying to write a script on my own and I'm trying to make something that looks through my folders and return a list, and I'm keep getting this TypeError: descriptor 'append' for 'list' objects doesn't apply to a 'str' object

    anyone have any ideas? Thank you so much!

    import os

    path = input("Where you want to look?")

    myFolder = list()
    print("Here's your list of folders:")
    for dirname in os.listdir(path):
    f = os.path.join(path,dirname)
    if os.path.isdir(f):
    for item in f:
    myFolder = list.append(f)

    print(myFolder)


    I've tried to change myFolder = list() to myFolder = list[] which resulted "none"

    Continue reading...

Compartilhe esta Página