So I want to read each character (separated by spaces) of each line of a text file and add them to a seperate index of a list for each line.
file = open("theTextFile.txt", 'r+')
pal = []
words = file.split(' ')
pal.append(words)
print(pal)
split_line(file)
The text file has a single character separated by a space for each line. The editor wouldn't allow for my punctuation from the text file, but below is an example of what it looks like.
r o t o r
r a c e c
This is what I did to solve my issue:
lines = open('theTextFile.txt','r')
secondList = []
for line in lines:
line = line.split()
secondList.append(line)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments