I have a list like this:
[(0, 1), (0, 2), (0, 3), (1, 4), (1, 6), (1, 7), (1, 9)]
That I need to convert to a tuple that looks like this:
[(0, [1, 2, 3]), (1, [4, 6, 7, 9])]
This is the code I have:
friends = open(file_name).read().splitlines()
network = []
friends = [tuple(int(y) for y in x.split(' ')) for x in friends]
return friends