1

I have a file of numbers separated by space, like this:

1 2 3 4

2 5 1 4

3 2 1 3

2 3 4 5

I want to write a python program that takes this file as input and store them in a list of list:

[[1, 2, 3,4], [2, 5, 1, 4], [3, 2, 1,3], [2, 3, 4, 5]]

Do you have any idea how can I do that? my code is as below to read the file.

file_text = open("text", "r")

file = file_text.read()

I am trying solutions of the related problem asked before, but I am getting error(ValueError: too many values to unpack). I am a bit confused. I would be happy if anyone could help me with that.

say.ff
  • 373
  • 1
  • 7
  • 21
  • I have found the exact answer of my question. here it is the link:http://stackoverflow.com/questions/12271503/python-read-numbers-from-text-file-and-put-into-list – say.ff Mar 28 '17 at 16:29

0 Answers0