def get_shared_prefix(w1, w2):
    """Get a string which w1 and w2 both have at the beginning."""
    shared = ""
    for i in range(1, min(len(w1), len(w2))):
        if w1[:i] != w2[:i]:
            return shared
        else:
            shared = w1[:i]
    return shared