Advertisement
Niksko

Untitled

Mar 24th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. filename=input("Enter the filename: ")
  2. file=open(filename,'r')
  3. line=file.readline()
  4. outlist = []
  5. # While we haven't got an empty line meaning the end of the file
  6. while(len(line)!=0):
  7.     # Split the line into tokens
  8.     split_line = line.split()
  9.     # Get a new line from the file
  10.     line=file.readline()
  11.     # Loop over all of the tokens in the split_line and convert them to ints, then append to our int_line
  12.     int_line = []
  13.     for element in split_line:
  14.         int_line.append(int(element))
  15.     outlist.append(int_line)
  16. print(outlist)
  17. file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement