Python tuple program to join tuples if the initial elements of the sub-tuple are the same

This Python Tuple program will check the initial value of all sub-tuples, if the initial value of two sub-tuple are the same, then it will merge both the tuple.

Input:
[(3,6,7),(7,8,4),(7,3),(3,0,5)]

Output:
[(3,6,7,0,5),(7,8,4,3)]

				
					# take input list value that contains multiple tuples
l1 = [(3, 6, 7), (7, 8, 4), (7, 3), (3, 0, 5)]

# initiate  a variable to store the required output
output = []

# initiate a loop with range of length of list l1.
for i in range(len(l1)):
    # initiate nested loop
    for j in range(i+1, len(l1)):
        # check any two same tuple initial values are same
        if l1[i][0] == l1[j][0]:
            # if two tuple initial value are same, then combine both tuple.
            # and store in output list.
            output.append(tuple(list(l1[i]) + list(l1[j][1:])))
        else:
            continue

print(output)
				
			
Output:
				
					# Output:
[(3, 6, 7, 0, 5), (7, 8, 4, 3)]