Python: Exporting text list to a text file
Question: I am new to Python and I was wondering how to save this hashed password list
(stored in variable _passwords_)

    
    
    ['73868cb1848a216984dca1b6b0ee37bc', '2de9210e9173ca4151bb220a2ded6cdb', '8c064f4067cf0c59c68ec281f5786cb2']
    

to a text file in the format:

    
    
    73868cb1848a216984dca1b6b0ee37bc
    2de9210e9173ca4151bb220a2ded6cdb
    8c064f4067cf0c59c68ec281f5786cb2
    

currently I am able to save it to a text file however it saves as

    
    
    ['73868cb1848a216984dca1b6b0ee37bc', '2de9210e9173ca4151bb220a2ded6cdb', '8c064f4067cf0c59c68ec281f5786cb2']
    

current code to save file:

    
    
    f = open( 'hash.txt', 'w' )
    f.write(repr(passwords) + '\n' )
    f.close()
    

Please help :) Thank you

Reason for wanting to save in text is so I can call that list in a new script
to decrypt them however because it saves as a list (and imports as a list) it
creates a list in a list and messes up my decryption script.

Edit: Thank you all for the great answers :) its a huge help!


Answer: You can use the following code :

    
    
    f = open( 'hash.txt', 'w' )
    for a in passowrds:
     f.write(a + '\n' ) #you have to pass them as separate variables 
    f.close()
    

Whenever you have to take out take out values from a list, you can use the
_for loop_ Example

    
    
    list = ["cat","dog","lion"]
    for animal in list:
       print animal
    

This will print each animal in the list. You can use any other variable name
in place of animal.

