l=["carbon","cart","carrot","cat"] l.sort(key=lambda x: len(x)) m,result=1,"" for i in range(len(l[0])): if len(set(word[i] for word in l)) != 1: break result+=l[0][i] print(result)
این رو هم با set نوشتم