def longest_common_substring(s1,s2):
    """Returns longest common substring of two sequences."""
    # Make sure that s1 is the shorter one
    if len(s1) > len(s2):
    # If s1 was shorter, then switch sequence order
        s1, s2 = s2, s1
    # Start with the entire sequence and shorten
    substr_len = len(s1) # Define substring of length of s1
    # While substring is longer than zero, iterate.
    while substr_len > 0:
        # Try all substrings
        for i in range(len(s1) - substr_len+1):
            # Check if the whole string is in the sequence 2, if not ,then shorten
            # and start from beginning
            if s1[i:i+substr_len] in s2:
                return s1[i:i+substr_len]

        substr_len -= 1
    # If we haven't returned, there is no common substring
    return ''