def longestCommonPrefix(*sequences):
 if (len(sequences) == 1):
  return sequences[0]
 sequences = [pair[1] for pair in sorted(((len(fi), fi) for fi in sequences))]
 if (not sequences):
  return None
 for (i, comparison_ch) in enumerate(sequences[0]):
  for fi in sequences[1:]:
   ch = fi[i]
   if (ch != comparison_ch):
    return fi[:i]
 return sequences[0]

def longestCommonPrefix ( * sequences ) : if ( len ( sequences ) == 1 ) : return sequences [ 0 ] sequences = [ pair [ 1 ] for pair in sorted ( ( ( len ( fi ) , fi ) for fi in sequences ) ) ] if ( not sequences ) : return None for ( i , comparison_ch ) in enumerate ( sequences [ 0 ] ) : for fi in sequences [ 1 : ] : ch = fi [ i ] if ( ch != comparison_ch ) : return fi [ : i ] return sequences [ 0 ]
returns longest common prefix occuring in given sequences reference: URL .