Cleaning up nested for loops in python
<p>I have this code:</p>

<pre><code>def GetSteamAccts(): #Get list of steam logins on this computer.
    templist = []
    Steamapp_Folders = ["C:\\Program Files (x86)\\Steam\\steamapps\\", "C:\\Program Files\\Steam\\steamapps\\"] #Check both of these directories.
    for SF_i in range(len(Steamapp_Folders)):
        if os.path.exists(Steamapp_Folders[SF_i]): #If the directory even exists...
            Steam_AppDir_Items = os.listdir(Steamapp_Folders[SF_i]) #List items under steam install directory.
            for S_AD_i in range(len(Steam_AppDir_Items)): #Make sure the user doesn't have any files in here...
                if os.path.isdir(Steamapp_Folders + Steam_AppDir_Items[S_AD_i]): #If our path is a directory...
                    templist.append(Steam_AppDir_Items[S_AD_i])  #Add it to our list of logins.
                                                                 #(If some idiot puts extra folders in here,
                                                                 #it's their own damn fault when it shows on the list.)
    return templist #Return a (not so) properly filtered list of steam logins.
</code></pre>

<p>My problem is, it looks AWFULLY ugly to me.  I made a list of 2 paths (only 1 will ever exist), loop over those paths, then I have to get a list of the items in those paths, and then traverse those and filter out non-directories from that in order to get a pseudo-list of steam logins on a users computer.  (Basically just getting a list of any existing directories (directories only!) under either of those 2 paths)</p>

<p>Is there a shorter way of doing this (Other than condensing for loops into single lines?)?</p>

<p>I would much rather be given an english-worded solution so I can put it together myself; rather than code.  It's the only way I'll truly learn the proper way.  Even a nice little hint or excerpt so I can figure it out on my own would be nice.</p>

<p>And: Do lists in for loops always have to be traversed like:</p>

<pre><code>for x in range(len(somelist)):
</code></pre>

<p>or is there something shorter than using range(len( ?</p>
