List comprehension for reading lists of integers As of reading the following input.txt file:

1 6 14
1 2 7
1 3 9
2 3 10
2 4 15
3 6 2
3 4 11
4 5 6
5 6 9


I wanted to make a list of lists containing each line as a list of integers

[[1, 6, 14],
 [1, 2, 7],
 [1, 3, 9],
 ...
 [5, 6, 9]] 


I achieved that by doing the following

with open('input.txt', 'r') as f:
    # gets lines as list of strings [['1, 2, 3,', ...]]     
    nodes_list = [n.split() for n in f.readlines()] 
    # convert strings inside the lists to int's [[1, 2, 3], ...]
    nodes_list = [[int(y[0]), int(y[1]), int(y[2])] for y in nodes_list]


Is there any way that I can achieve the same with a single comprehension list, without the need of having two separated ones? If not, maybe some cleaner way of doing it?
You can use a map to give you what you want in a single line:

with open('input.txt', 'r') as f:
    nodes = [list(map(int, line.split())) for line in f]


An explanation of how it works:

f.readlines() iterates over the lines, with line endings removed

line.split() gives you an iterable over the space-separated characters

map(int, ...) does the conversion to int for every element

list(...) converts it to a list to give you a list of lists