def exportTextList(fileInput, wordList): fileOpen = open(fileInput) for line in fileOpen: line = line.rstrip("\n\r") lineList = line.split() wordList = wordList + lineList return wordList def main(): fileInput = 'PlayerNames.txt' wordList= exportTextList(fileInput, wordList) print wordList
My code summary:
I'm taking a txt file, playernames, and i'm stripping all of the line breaks and creating a list of each word in the file.
If i print wordList before I return it, I get the correct print out
But when I try to return it, and then print word list after in the main function, it just prints a blank list.
Anybody know what's going on?
Thanks in advance