If I have a text file:
Hello World How are you? Bye World
How would I read it in a multidimensional array like this:
[["Hello", "World"], ["How", "are", "you?"], ["Bye" "World"]]
I 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 to read a file in a multidimensional array?
source share