if len(lists) >= 1:
    resultlist = [lists[0]]
if len(lists) > 1:
    for l in lists[1:]:
        listset = set(l)
merged = False
for index in range(len(resultlist)):
    rset = set(resultlist[index])
if len(listset & rset) != 0:
    resultlist[index] = list(listset | rset)
merged = True
break
if not merged:
    resultlist.append(l)
print(resultlist)
Merge lists that share common elements