I am learning Python & I am trying to read a text file, store each word in the file in a list or turple(which would be better?) then output/print each word on a new line.
I cannot seem separate the file contents by words. Also I am sure I am not using a for loop to display the contents of a list and/or turple correctly.
Any suggestions would be very helpful
file = open('data.txt,'r') fileContent = file.read() # go through each element of fileContent & separate the strings into words for word in range(fileContent): fileContent[word].split() # print each word(element) in the list fileContent on a different line for words in range(fileContent): print fileContent[words] file.close()