1.11M Members

Format Question

 
0
 

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
 
1
 

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)]
 
0
 

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

Question Answered as of 1 Year Ago by pyTony
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article