Really quick question, if I want to return the data that is returned by snesVar in videoGame as a string on every line, what is the correct code to use?

def videoGame():
    count = 0 
    snesVar = []
    for data in os.listdir('/SNES/SNES Roms'):
        if data.endswith('.src') or data.endswith('.srm'):
            snesVar.append(data)  
    return snesVar

def videoGame2():
    gbaVar = []
    count = 0 
    for data in os.listdir('GBA'):
        if data.endswith('.gba') or data.endswith('.gb'):
            gbaVar.append(data)
    return gbaVar

def videoGame3():
    ndsVar = []
    count = 0 
    for data in os.listdir('NDS'):
        if data.endswith('.nds') or data.endswith('.ds'):
            ndsVar.append(data) 
    return ndsVar

Your functions are duplicates, you only need one to return the file names. I do not understand your question.

def video_game(game_dir='/SNES/SNES Roms', extensions=('.src','srm')):
    return [file_name for file_name in os.listdir(game_dir) if data.endswith(extensions)]

Got it, that worked...sorry if that sounded unclear. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.