I need to read a file that contains this:
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 2 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1

... into a 2-Dimensional python list. This list has already been built in the main function of my program. Here is the code:

def main():
        old = [ [" "]*COLUMN  for i in range(ROW)]
        user_file = input("blah blah blah: ")
        getfromfile(old,user_file)

def getfromfile(old,user_file):
      old = open(user_file, 'r')
      old = old.read()

- COLUMN is a global variable with a value of 10, the same for ROW

...When I return old to the main function and print old it just prints an empty 10x10 array. I know in this piece of code I dont return it at all, that is because I have tried multiple ways of changing the getfromfile function and for some reason I can't figure out how to actually read the file INTO the 2-D list. Any help would be greatly appreciated!

Nice.. Chances are that post was created by one of my classmates. Thanks for the help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.