Python Write To File Error: Lists

181 views Asked by At

I've been trying to write two tuple lists I've created to a txt file called WorldSeriesWinnersND.txt HOWEVER, though no error messages come up when the program is run, the txt file remains unchanged. I have tried several different ways to get the tuples written to the file, two of which I will illustrate below. Please let me know what I'm missing.

def createFileNoDuplicates(winnersND, winsTuple):

    wins_file = open('WorldSeriesWinnersND.txt', 'w')

    wins_file.write("\n".join(winnersND))        

    wins_file.write("\n".join(winsTuple))

    wins_file.close()

and

def createFileNoDuplicates(winnersND, winsTuple):

    wins_file = open('WorldSeriesWinnersND.txt', 'w')

    for item in winsTuple:
        wins_file.write('%s\n' % item)

    wins_file.close()
0

There are 0 answers