Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- filename=input("Enter the filename: ")
- file=open(filename,'r')
- line=file.readline()
- outlist = []
- # While we haven't got an empty line meaning the end of the file
- while(len(line)!=0):
- # Split the line into tokens
- split_line = line.split()
- # Get a new line from the file
- line=file.readline()
- # Loop over all of the tokens in the split_line and convert them to ints, then append to our int_line
- int_line = []
- for element in split_line:
- int_line.append(int(element))
- outlist.append(int_line)
- print(outlist)
- file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement