If I have a text file like this:
Hello World
How are you?
Bye World
How would I read it into a multidimensional array like this:
[["Hello", "World"],
["How", "are", "you?"],
["Bye" "World"]]
I have tried:
textFile = open("textFile.txt")
lines = textFile.readlines()
for line in lines:
line = lines.split(" ")
But it just returns:
["Hello World\n", "How are you?\n", "Bye World"]
How do I read the file into a multidimensional array?
lines = map(str.split, open('testFile.txt'))