def compare_and_construct(s1, s2):
    result = ''
    # Iterate through each character in the strings
    for char1, char2 in zip(s1, s2):
        # Check if the characters are the same
        if char1 == char2:
            result += 'v'
        else:
            result += '-'
    
    return result

# Example usage:
string1 = "abcdefghij"
string2 = "axxxxxxxij"

result_string = compare_and_construct(string1, string2)
print(result_string)

 

by chatgtp

+ Recent posts